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

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...

Erik N.
Erik NAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 .... ?
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,

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erik NAuthor Commented:
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.....

Erik N.

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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 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 - I don't. (Except my image database .. 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 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.
In my first sentence I meant:
"I could not WRITE a viewer for DWG _and_ DXF..."
Erik NAuthor Commented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Graphics Software

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.