Solved

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

Posted on 1997-09-10
6
610 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
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
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 60 total points
Comment Utility
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
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Expert Comment

by:ptiemann
Comment Utility
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
Comment Utility
In my first sentence I meant:
"I could not WRITE a viewer for DWG _and_ DXF..."
0
 

Author Comment

by:Erik N
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
TVirtualStringTree  search using TEdit 7 79
Adobe Illustrator CC 2015 - colors disappeared 3 86
Simple 3D CAD 18 91
Microsoft Paint 10 58
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
In this Micro Tutorial viewers will learn the basic shortcuts and functions of Illustrator. The viewer will learn about the paintbrush tool, anchor points, font sizing, and more.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now