Examples Delphi

Subject: RE: D4: JPEG
JPEG support is available in Delphi 3 (and, I guess, Delphi 4). Just Use
JPEG and use LoadFromFile() to display the JPEG as the TImage's Picture.
E.g.:
use
JPEG;
procedure LoadPicture(ImageFileName: String);
var
SplashImage : TImage;
begin
SplashImage :=3D TImage.Create(ParentForm);
SplashImage.Picture.LoadFromFile(ImageFileName);
end;
will load any .BMP, .ICO, .EMF, .JPG (.JPEG), .WMF file passed as
ImageFileName.
Note: The Picture loader in the (D3) IDE doesn't include JPG/JPEG as
supported file formats. You could probably make a new component that woul=
d
let you assign a JPEG image in the IDE and, therefore, compile it into the
=2EEXE and, therefore, probably load the picture faster when the program
executes.
Steve Helgeson
Lamplighter Software
-----Original Message-----
From: owner-delphi@Kyler.com [mailto:owner-delphi@Kyler.com]On Behalf Of
Niclas Astrom
Sent: Monday, March 08, 1999 12:38 PM
To: delphi@Kyler.com
Subject: D4: JPEG
How can I import/export JPEG images from a TBitmap ? Is there any
freeware addons ? Source ?
Thanks,
Niclas Astrom
Teknikhuset
Sweden
****************************************************************************
Date sent: Tue, 09 Mar 1999 09:52:14 +0100
From: "Gabriele Ghirardini"
To: Delphi@Kyler.com
Subject: Re: D4: JPEG
Send reply to: Delphi@Kyler.com
Working with JPEG is very easy.
Try this:
uses Graphics, Jpeg;
function LoadJPEG(const psFileIN: PChar): TPicture;
var
imgJPG : TJPEGImage;
picReturn : TPicture;
begin
imgJPG := TJPEGImage.Create;
picReturn := TPicture.Create;
try
imgJPG.LoadFromFile(psFileIN);
picReturn.Bitmap.Assign(imgJPG);
except
picReturn.Free;
picReturn := nil;
end;{Try}
imgJPG.Free;
LoadJPEG := picReturn;
end;
function SaveJPEG(picToSave: TPicture; const psFileOUT: PChar):
boolean;
var
bReturn : boolean;
imgJPG : TJPEGImage;
begin
bReturn := False;
imgJPG := TJPEGImage.Create;
try
imgJPG.Assign(picToSave.Bitmap);
imgJPG.SaveToFile(psFileOUT);
bReturn := True;
finally
imgJPG.Free;
end;{Try}
SaveJPEG := bReturn;
end;
(This is a D3 source)
bye,
Ghira
Niclas Astrom wrote:
> How can I import/export JPEG images from a TBitmap ? Is there any
> freeware addons ? Source ?
>
> Thanks,
>
> Niclas Astrom
> Teknikhuset
> Sweden
*****************
If you can use this Delphi-Standard depends on the type of the
Delphiversion. If you has the desktop (smallest) version, JPEG is not
supported. But there are serval shareware/freeware tools to handle
JPEG's. I use the "TJPEGImage component" from Luciano Bajo Eloy. You
can download it from one of the Delphi-Sites (e.g. Torrys Homepage).
> Working with JPEG is very easy.
>
>
> Try this:
>
> uses Graphics, Jpeg;
>
> function LoadJPEG(const psFileIN: PChar): TPicture;
> var
> imgJPG : TJPEGImage;
> picReturn : TPicture;
>
> begin
> imgJPG := TJPEGImage.Create;
> picReturn := TPicture.Create;
>
> try
> imgJPG.LoadFromFile(psFileIN);
> picReturn.Bitmap.Assign(imgJPG);
> except
> picReturn.Free;
> picReturn := nil;
> end;{Try}
>
> imgJPG.Free;
>
> LoadJPEG := picReturn;
> end;
>
> function SaveJPEG(picToSave: TPicture; const psFileOUT:
> PChar): boolean;
> var
> bReturn : boolean;
> imgJPG : TJPEGImage;
>
> begin
> bReturn := False;
> imgJPG := TJPEGImage.Create;
> try
> imgJPG.Assign(picToSave.Bitmap);
> imgJPG.SaveToFile(psFileOUT);
>
> bReturn := True;
> finally
> imgJPG.Free;
> end;{Try}
>
> SaveJPEG := bReturn;
> end;
>
> (This is a D3 source)
>
>
> bye,
> Ghira
>
>
>
> Niclas Astrom wrote:
>
> > How can I import/export JPEG images from a TBitmap ? Is
> > there any
> > freeware addons ? Source ?
> >
> > Thanks,
> >
> > Niclas Astrom
> > Teknikhuset
> > Sweden
*****************
printing bitmaps:
As Joe Hecht will tell you in Borland's Delphi.Graphics forum, you can't
reliably print a bitmap (which is actually a DDB, a Device Dependent
Bitmap). Instead, you have to change it to a DIB (Device INdependent
Bitmap) and use the StretchBits function to get it onto the printer's
canvas. I'm pretty sure that the Borland website has a TI (technical
information) document that explains it clearly.
*****************************
the Intel JPEG libraries may be faster and less prone to errors
than other routes to manipulating images: see
http://www.david-taylor.pwp.blueyonder.co.uk/software/runtime.html