Link to home
Start Free TrialLog in
Avatar of WarheaD
WarheaD

asked on

Saving jpeg as bitmap

How do i save a bitmap as a jpeg, using a TImage.
Avatar of inthe
inthe

hi
try this:
image1.picture.savetofile('c:\bmpasjpg.jpg');

Regards Barry
Barry: That is correct but Warhead will need to add teh jpeg unit from the D4 CD (in the info\Extras\jpeg directory on the CD)

Cheers,

Raymond.
hi
Raymond i just did this in d4(no jpg components) and it worked fine how come you have to add jpg unit ?
Regards Barry
Avatar of WarheaD

ASKER

hi

i've already got the jpeg stuff in my delphi, but i dont have delphi on this machine so i'll get back later.

thanx
Barry: The jpeg code is not included in the TImage components by default (its pretty chunky and adds some 150k to your app). Try loading the .JPG files into TImage and see what happens.

Did it produce a JPEG file, or a BMP file with a JPG extension?

Raymond.
Sorry raymond you right without jpg it produce bmp with jpg extension
Regards Barry
Avatar of WarheaD

ASKER

I'm back (a week later)

I have included the jpeg.dcu into my uses, but i still get a bitmap with jpeg extension.
When I do it the other way round( i.e jpeg to bitmap), i get a jpeg with bitmap extension.


Avatar of WarheaD

ASKER

I'm back (a week later)

I have included the jpeg.dcu into my uses, but i still get a bitmap with jpeg extension.
When I do it the other way round( i.e jpeg to bitmap), i get a jpeg with bitmap extension.


first your question was :
How do i save a bitmap as a jpeg, using a TImage.well that question is answered,what you want to do is convert a jpg to a bitmap which is different,below is a link to efg's source for doing this.it is source for bmp to jpg(visa versa) for commandline ,but you should be able to see whats happening
Happy coding
Regards Barry

http://www.efg2.com/lab/library/delphi/graphics/BMPtoJPG.PAS.txt
also go here:
http://www.efg2.com/lab/Graphics/BMPJPG.htm

and download bmpjpg.zip,has full sources inside for doing conversions
Well, here is the missing bit I think...

You can make another TImage then just assign the graphic to the bitmap to convert the graphic to the bitmap (the graphic property will contain the JPEG image you loaded into it). Like this:

  image2.picture.bitmap.assign(Image1.picture.graphic);

However, if you want to go both ways this is perhaps not a suitable solution...

Cheers,

Raymond.
 
Hi All,
Interesting, browsing through these back end questions, I'm currently working on a Word doc to JPEG converter, and I see some input here, I had already all the pieces working only with quite some overhead.

:O)Always happY.
Avatar of WarheaD

ASKER

Hey inthe

The conversion doesn't work either way, but thanks for the links. I'll give you the points anyway, because everyone here says it should work too. So just answer again so i can give them to you.
ASKER CERTIFIED SOLUTION
Avatar of inthe
inthe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WarheaD

ASKER

hi inthe

Although the answer wasn't correct, i've assigned the ponts to you.

Cheers

P.S BoRiS E-mailed me the correct answer!