Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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

Posted on 1997-09-10
Medium Priority
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...

Erik N.
Question by:Erik N
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

Expert Comment

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

Accepted Solution

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,

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

Erik N.

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

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.

Expert Comment

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

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.

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Not only does Prezi allow you to create non-linear presentations, it also makes it easy to apply transition animations between your frames. Learn how to apply a fade-in transition to select items and entire frames in this tutorial Select "Edit Path"…
In addition to being a great web-based presentation tool, Prezi also makes it easy to save your presentation as a PDF to share with others as well. Learn how in this tutorial. Select the share icon from the top menu in your Prezi editor: Select "D…
Suggested Courses

618 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