?
Solved

Viewing DWG,DXF,HPGL,BMP and Gif's..

Posted on 1997-09-10
6
Medium Priority
?
622 Views
Last Modified: 2013-11-19
I'd like to be able to view DWG,DXF,HPGL,BMP and Gif's  by using one component, like the original TImage - Component. If there isn't any component with these capabilities, maybe I can manufacture one. The problem here is that I am not used to making my own components, however I guess it's not that hard once you've learned it. I'd like some suggestions on how to solve this problem, either by giving me a name on a component already existing, or give me a good way to start making my own component.

I looked at DR DWG, but it's way too expensive for me, besides, it doesn't handle all of the fileformats i'd like it to...

I run Delphi Developer 2.0...

Thanx!
Erik N.
0
Comment
Question by:Erik N
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:mirek071497
ID: 1344549
For all this format you probably need own component, but for some of this format you can use component on the network.
Tell me if you can make new copmonent over TImage ?
If you can then probably you need know how to read DXF, Gif .... ?
0
 

Accepted Solution

by:
ptiemann earned 120 total points
ID: 1344550
Hello Erik,
If really want to do this.. (read last paragraph in my reply!)
I'd take a look at \source\vcl\graphics.pas, class TPicture:

{ TPicture is a TGraphic container. It is used in place of a TGraphic if the graphic can be of any TGraphic class.

  LoadFromFile and SaveToFile are polymorphic. For example, if the TPicture is holding an Icon, you can LoadFromFile a bitmap file, where if the class was TIcon you could only read .ICO files. }

They dirty way would be to modify TPicture directly. You should derive some "TMyPicture" from TPicture and write your own "LoadFromFile" depending on the file format.

Now, here, why I WOULD NOT DO THIS:

- Delphi's way to handle palette conflicts in not very good. Palette problems occur, when you have a 256-color machine and display more than one picture with different palettes simultaneously. So you better work on the palette handling as well.

- Implementing image file formats can take you much time. DWG,DXF,HPGL,BMP and Gif's.. ? You're mixing vector and raster (BMP, GIF) formats.
I have implemented BMP, GIF, JPEG, PNG, TIFF, RLE .. 13 image file formats. All raster, BTW. Believe me, it's a lot of work.
Ok, if you stick with BMP and GIF of the raster formats, you took the 2 easiest ones.
I once found PD sources for .DWG which I temporarily integrated in my viewer. I don't want to discourage you, but you're going to spend some time on this..

Another idea:
With Word and other packages, there are those Import/ Export plugin filters that read/ write a file and deliver you a Windows DIB handle. They're really easy to work with, I added their usage to my graphics application too.
And there are import filters for the vector formats as well as for raster formats. Hm, the latest version of _Word_ missed GIF, I think. If you want to sell your application you need to think about the license situation. Most people have some office software installed, so they have those filters.

I don't know for what purposes you need it.. hope this is some useful input for you,
Peter
0
 

Author Comment

by:Erik N
ID: 1344551
To ptiemann..

It seems to be a little harder than I thought from the beginning...
What if I only view vector-formats? Is it easier then?
Maybe there is a component somewhere wich handle the formats Dwg,Dxf (and perhaps HPGL). I am not an expert-programmer so I may have to limit my demands a little.....

Thanx!
Erik N.

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:ptiemann
ID: 1344552
I could not find a viewer for DWG _and_ DXF because I didn't find the specification for one of the formats. The other one, I had found something from a third party. It could be that you need to experiment with sample files and detect yourself, how changing the file has influence on the resulting output file. That way you get to know the format. Have fun :-)

Since you said that you are not an expert programmer, I would strongly recommend to PURCHASE something for whatever you need. A easy file format like BMP - the easiest one! - takes more than one day, you have to deal with things like:

- memory allocation (bitmap is big, insufficient RAM)

- picture has 24 bits/pixel, graphic card has only 8 bpp. Just this stuff takes several thousands of lines of code, if you want to solve it.. hot buzz words are: "Color reduction" - how to display s.th. that needs 1Mio colors with 256 colors, methods to do so are: "Dithering" (I know 3 dither algorithms), "Heckbert quantisation" or just "nearest color" (looks ugly) etc.

- palette management (as said before, 2 pictures with conflicting palette entries want to be displayed simultanously - Windows has something built in for that, but ..)

- use a HBMP (faster for display) or the raw bits (allows you to manipulate easier)..? Best choice: keep the raw bits in memory and have a HBMP for a proxie. If you happen to come to this point, take a look at the DIB driver - it's a lot more reliable than the normal (HBMP) drivers. Yes, there's functions you better will not use because some graphic card manufacturers did a buggy job. I'm talking about "StretchBits" - whereas the matching DIB function works fine.

- BMP is harmless.. GIF files are compressed. But you'll find dozens of solutions for GIF already.. everybody seems to feel the need to code that once in his/ her live - me too. It's not exactly trivial, but well described. You may want to remember that there is some license problem for GIF files (actually: the LZW algorithm)- Unisys forces you to pay some fee. Better use the PNG format or at lease support both. I guess this is why Word doesn't have GIF any more in its list

==> unless you are a hobby programmer who doesn't care for his/ her leisure time - and in such a case it doesn't matter how slow, buggy or late the product is.. - invest some money and buy a ready solution.
I don't say this because I would sell s.th. - I don't. (Except my image database http://www.preview.org/e .. see "TrueBase")

Your subject is a perfect example where people can reuse code from a third party. As indicated, I personally implemented 13 image file formats wich took me together with the surrounding application about 3 years. Three years. 2 of them on the file formats, I'd say.
When I wanted to port the app to Win32, I decided to buy a library; I chose "ImageLib", which is $500. Certainly an expensive component, but it would have taken me more time than $500 is worth.

Don't waste your time! I'm sure your live is more interesting spending it other ways.

ImageLib does not support the vector formats, but I remember to have seen a component which does about 30 image file formats including vector formats. The name was s.th. like "Silver..".
In Germany, around 1994, it was like $850 for _one_ platform, e.g. Win32 or Unix. You also could get the sourcecode for about $2000.. but
(a) software is more expensive in Europe in general
(b) prices probably changed

If you don't sell your application very widely = you know, who is going to use it, try the Adobe Import filters which I mentioned in my first reply. Reliable, little coding and free.
I can help you with that.
Peter
0
 

Expert Comment

by:ptiemann
ID: 1344553
In my first sentence I meant:
"I could not WRITE a viewer for DWG _and_ DXF..."
0
 

Author Comment

by:Erik N
ID: 1344554
Thank you very much for your excellent answer ptiemann!!!
I won't try this, since it seems that I won't make it within a reasonable amount of time....

Erik N.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this tutorial viewers will learn how to create blended and gradiated shapes in Illustrator using the blend tool Draw two shapes, one of them in a different color: Select both and create a blend by going to Object > Blend > Make: Blends can also b…
In this second Micro Tutorial in the series,  viewers will learn more basic shortcuts and functions of Illustrator. In this tutorial you will learn about the eyedropper tool, zoom , ellipses and more.
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question