procedure TForm1.Button1Click(Sender: TObject);
var
BmpHnd,MaskHnd: HBitmap;
Bitmap1: TBitmap;
IntfImg1: TLazIntfImage;
ReaderXPM: TLazReaderXPM;
WriterXPM: TLazWriterXPM;
ReaderBMP: TLazReaderBMP;
WriterBMP: TLazWriterBMP;
{begin // that part works fine
Bitmap1:=TBitmap.Create; // create a bitmap (or use an existing one)
IntfImg1:=TLazIntfImage.Create(0,0,[riqfRGB, riqfAlpha, riqfMask]); // create the raw image for the screenformat you want
ReaderXPM:=TLazReaderXPM.Create; // create the XPM reader
IntfImg1.LoadFromFile('filenamein.xpm',ReaderXPM); // load the image
IntfImg1.CreateBitmaps(BmpHnd,MaskHnd); // create the bitmap handles
Bitmap1.Handle:=BmpHnd; // apply handles to the Bitmap1
Bitmap1.MaskHandle:=MaskHnd;
ReaderXPM.Free; // clean up
IntfImg1.Free;
// do something with the Bitmap1
// nothing to do...
IntfImg1:=TLazIntfImage.Create(0,0,[]); // create the raw image
IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle); // load the raw image from the bitmap handles
WriterXPM:=TLazWriterXPM.Create; // create the XPM writer
IntfImg1.SaveToFile('filenameout.xpm',WriterXPM); // save image to file
WriterXPM.Free; // clean up
IntfImg1.Free; }
//
begin // BMP black image size ok
Bitmap1:=TBitmap.Create; // create a bitmap (or use an existing one)
Bitmap1.PixelFormat:=pf24bit; // added by me
Bitmap1.SetSize(TargetImg.Width, TargetImg.Height);
//ok showMessage(inttostr(TargetImg.Width)+' '+inttostr(TargetImg.Height));
IntfImg1:=TLazIntfImage.Create(0,0,[riqfRGB, riqfAlpha, riqfMask]); // create the raw image for the screenformat you want
ReaderBMP:=TLazReaderBMP.Create; // create the BMP reader
IntfImg1.LoadFromFile('filenamein24.bmp',ReaderBMP); // load the image
IntfImg1.CreateBitmaps(BmpHnd,MaskHnd); // create the bitmap handles
Bitmap1.Handle:=BmpHnd; // apply handles to the Bitmap1
Bitmap1.MaskHandle:=MaskHnd;
ReaderBMP.Free; // clean up
IntfImg1.Free;
// do something with the Bitmap1
// nothing to do...
IntfImg1:=TLazIntfImage.Create(0,0,[]); // create the raw image
IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle); // load the raw image from the bitmap handles
WriterBMP:=TLazWriterBMP.Create; // create the XPM writer
IntfImg1.SaveToFile('filenameout24.bmp',WriterBMP); // save image to file
WriterBMP.Free; // clean up
IntfImg1.Free;
//
//begin // BMP black image size ok
Bitmap1:=TBitmap.Create; // create a bitmap (or use an existing one)
Bitmap1.PixelFormat:=pf32bit; // added by me
Bitmap1.SetSize(TargetImg.Width, TargetImg.Height);
IntfImg1:=TLazIntfImage.Create(0,0,[riqfRGB, riqfAlpha, riqfMask]); // create the raw image for the screenformat you want
ReaderBMP:=TLazReaderBMP.Create; // create the BMP reader
IntfImg1.LoadFromFile('filenamein32.bmp',ReaderBMP); // load the image
IntfImg1.CreateBitmaps(BmpHnd,MaskHnd); // create the bitmap handles
Bitmap1.Handle:=BmpHnd; // apply handles to the Bitmap1
Bitmap1.MaskHandle:=MaskHnd;
ReaderBMP.Free; // clean up
IntfImg1.Free;
// do something with the Bitmap1
// nothing to do...
IntfImg1:=TLazIntfImage.Create(0,0,[]); // create the raw image
IntfImg1.LoadFromBitmap(Bitmap1.Handle,Bitmap1.MaskHandle); // load the raw image from the bitmap handles
WriterBMP:=TLazWriterBMP.Create; // create the XPM writer
IntfImg1.SaveToFile('filenameout32.bmp',WriterBMP); // save image to file
WriterBMP.Free; // clean up
IntfImg1.Free;
end;