1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
VAR
BitmapHeader: pBitmapInfo;
BitmapImage : Pointer;
DelphiBitmap: TBitmap;
HeaderSize : DWORD;
ImageSize : DWORD;
LeadBitmap : BitmapHandle;
StartTime : DWORD;
BitmapInfo: TBitmapInfo;
begin
StartTime := GetTickCount;
DelphiBitmap := TBitmap.Create;
TRY
DelphiBitmap.LoadFromFile('D:\TEMP\TOTO.BMP');
Image1.Picture.Graphic := DelphiBitmap;
L_InitBitmap(@LeadBitmap, 0, 0, 24);
TRY
GetDIBSizes(DelphiBitmap.Handle, HeaderSize, ImageSize);
GetMem(BitmapHeader, HeaderSize);
GetMem(BitmapImage, ImageSize);
GetDIB(DelphiBitmap.Handle, DelphiBitmap.Palette, BitmapHeader^, BitmapImage^);
BitmapInfo := TBitmapInfo(BitmapHeader^);
TRY
// Complete conversion to Lead Tool BitmapHandle
L_ConvertFromDIB(
@LeadBitmap,
@BitmapInfo,
BitmapImage);
FINALLY
FreeMem(BitmapHeader);
FreeMem(BitmapImage)
END;
// QMS = quality more important than size
L_SaveBitmap('D:\TEMP\TOTO.CMP', @LeadBitmap, FILE_CMP, 24, QMS, nil); // Lead Proprietary
L_SaveBitmap('D:\TEMP\TOTO.EPS', @LeadBitmap, FILE_EPS, 8, 0, nil); // Encapsulated Postscript
// 20 here for Lead is like 80 for Delphi JPEGImage
L_SaveBitmap('D:\TEMP\TOTO.JPG', @LeadBitmap, FILE_JFIF, 24, MulDiv(255,20,100), nil);
L_SaveBitmap('D:\TEMP\TOTO.PCT', @LeadBitmap, FILE_PCT, 24, 0, nil); // Macintosh PCT
L_SaveBitmap('D:\TEMP\TOTO.PCX', @LeadBitmap, FILE_PCX, 24, 0, nil); // ZSoft PCX
L_SaveBitmap('D:\TEMP\TOTO.PNG', @LeadBitmap, FILE_PNG, 24, 0, nil); // Portable Network Graphics
L_SaveBitmap('D:\TEMP\TOTO.RAS', @LeadBitmap, FILE_RAS, 24, 0, nil); // Sun Raster
L_SaveBitmap('D:\TEMP\TOTO.TGA', @LeadBitmap, FILE_TGA, 24, 0, nil); // Truevision TARGA
L_SaveBitmap('D:\TEMP\TOTO.TIF', @LeadBitmap, FILE_TIF, 24, 0, nil); // TIFF
L_SaveBitmap('D:\TEMP\TOTO.WMF', @LeadBitmap, FILE_WMF, 24, 0, nil); // Windows Metafile
FINALLY
L_FreeBitmap(@LeadBitmap);
END
FINALLY
DelphiBitmap.Free
END; |