segunda-feira, 25 de junho de 2007

Lazarus in Ubuntu!

Finally!!! Endlich!!! Finalmente!!! =)

http://packages.ubuntu.com/gutsy/devel/lazarus

This, together with the fact that Mandriva and Fedora are only offering install DVDs now, instead of the usual CDs (I don't have a DVD burner), means one thing: It's time to move to Ubuntu!

And learn how to create a debian package for my Virtual Magnifying Glass =)

Saving HBITMAP to file

While implementing the dynamic mode of the magnifier I needed a function to save a HBITMAP to a file. A googled a lot, but I only found C code out there, so I had to convert this to Pascal. I just needed this for a quick test, so I needed to erase this from my software, but I will keep it here. Just in case I ever need it again or it helps someone.


procedure SaveBitmapToFile(bmp: HBITMAP);
var
myFile: file;
bmfh: BITMAPFILEHEADER;
begin
AssignFile(myFile, 'Test.bmp');
ReWrite(myFile, 1); // Define a single 'record' as 1 bytesvar

bmfh.bfType := Byte('B') + (Byte('M') shl 8);
bmfh.bfOffBits := sizeof(BITMAPFILEHEADER) + BitmapInfo.bmiHeader.biSize;
bmfh.bfSize := bmfh.bfOffBits + BitmapInfo.bmiHeader.biSizeImage;
bmfh.bfReserved1 := 0;
bmfh.bfReserved2 := 0;
//Write the bitmap file header
BlockWrite(myFile, bmfh, sizeof(BITMAPFILEHEADER));
//And then the bitmap info header
BlockWrite(myFile, BitmapInfo.bmiHeader, sizeof(BITMAPINFOHEADER));
//Finally, write the image data itself
//-- the data represents our drawing
BlockWrite(myFile, FImageData^, BitmapInfo.bmiHeader.biSizeImage);

CloseFile(myFile);
end;

Hello Blog

Just to test