Log in

View Full Version : Adding a bitmap to a form???



Rune Hacker
04-11-2007, 12:22 AM
Is there a way to have a bitmap at the begging of a script and then use it in the form? I found tutorials on how to use it as a separate file, but i want the bitmap inside the script. So far im thinking of soemthing like this, but idk.

Procedure LoadTheBitmap
begin
TheBitmap := BitmapFromString(30, 29, 'z78DABD97DD9' +
'2A4200C465F498190F4A58ABEFF232DCDC745A8888BB6BB50 959A' +
'9A9A1E4F4E7FFC2893FC38CB98EF5699FEDFB44FE7C421CF8 3234' +
'7995958C4F3C28B30EF9CE423131FB28A935992F83C770912 FE35' +
'7F43E8E31A57A698E2C61F9E79E2955D9E969C78E3B5D60EF F679' +
'228F12D7EFD7F22D34147DC628881A7FC10A9CC1C8FB85772 CBAC' +
'2BCC6B7E43FEF192C733727C8A123171F4B4D1DA30C3B3B60 D72D' +
'8D6CE75B5FE3579498B76EE2797E70DDA48134D71A6859648 B453' +
'8A9FE8F2DC631ED5B365D615E67572543D49BBCAB926BFC13 C872' +
'52C24E4C855CF602E9E1B72CDAFBB18E905E6C1AF73AE56E8 B56D' +
'FC4DD8BE500D336C231BA8E0375D9C7C0BB60BDB4B494E436 EF69' +
'6BF303B9F7C0A7BF804AE09816754E404F5972E6C2F9A5CE5 BC67' +
'BBFE7EF3EC395098F204B30F2924ACC4BA1EE11C75BC1774D 1CB9' +
'5EE486706EBB438B7B62B33F929CFC32F7EC92DFBE0910D5A E93B' +
'507FE7EF74517BD1E426339A5C33D76C20D5F05C12522BBAF 8D7B' +
'D80DF6446E7A4FE2CFE3BB467AC4454F08F7431CEDF49514D 8B59' +
'A196D9C9F74320D72BB166FB9A7FDCFFB5F942DE4BF809737 079D' +
'495A81252EB08B9E67F961CCDACEF33C5B6659E8F39CDA961 2E09' +
'B1E40DFF786646CC17DBBD5BC109F332E723C86D6E714B4D3 5F63' +
'D906BFEF1CC8C9B57B64F988BED13669AF3689861BB477E97 FFD2' +
'7C73B7C14ABC64D63B9E26AFCC9AFC5D7ECB5C6CDBB346D3F 6986' +
'BB68BEDC6F908FFEFE4E6C4B93EC13573DDFDCAAA7C8DFF9A D9EC' +
'D83DC33DF2BAFBE1AC01798FFF2572BBFB8DDF481BDB58952 0EFF' +
'09F98EF908FD8461D313C9413E776B7BF4CDEE1BFFB867542 8EDD' +
'BBA4A5CB3F9219BDCF982EF45BF3B8E1EBB7EF137E2407F75 86DF' +
'E66FE2DE7335A3DF5E9D34B4E53D10BBE0B746412F596D567 FCCF' +
'EABB56EFF2FF529F3DF70FB9DE4B0C');
end;


Procedure AddPic;
var
Picture : Integer;
Canvas : TCanvas;
begin
Picture := LoadBitmap(TheBitmap);
Canvas := GetBitmapCanvas(Picture);
CopyCanvas(Canvas, frmDesign.Canvas, 1, -1, 300, 520, 0, 0, 315, 520);
end;

Procedure FormPaintTheBitmap(sender: TObject);;
begin
Addpic;
end;
I do have the frmDesign.OnPaint := FormPaintTheBitmap; and everything else. Im just tryign to figure out how to add this bitmap to the background of the form.

ShawnjohnSJ
04-16-2007, 03:52 AM
Seems right.

Picture := LoadBitmap(TheBitmap);
Canvas := GetBitmapCanvas(Picture);

I dont think you need the 'LoadBitmap' because its already inside the script.

So try just

Canvas := GetBitmapCanvas(TheBitmap);

SKy Scripter
04-16-2007, 04:12 AM
hmmm maybe this will help


Program New;

Const
Xpos = 10;
YPos = 10;
Width = 200;
Height = 200;


Var
MainForm : TFORM;
BitMap: Integer;


Procedure LoadTheBitmap;
begin
BitMap := BitmapFromString(30, 29, 'z78DABD97DD9' +
'2A4200C465F498190F4A58ABEFF232DCDC745A8888BB6BB50 959A' +
'9A9A1E4F4E7FFC2893FC38CB98EF5699FEDFB44FE7C421CF8 3234' +
'7995958C4F3C28B30EF9CE423131FB28A935992F83C770912 FE35' +
'7F43E8E31A57A698E2C61F9E79E2955D9E969C78E3B5D60EF F679' +
'228F12D7EFD7F22D34147DC628881A7FC10A9CC1C8FB85772 CBAC' +
'2BCC6B7E43FEF192C733727C8A123171F4B4D1DA30C3B3B60 D72D' +
'8D6CE75B5FE3579498B76EE2797E70DDA48134D71A6859648 B453' +
'8A9FE8F2DC631ED5B365D615E67572543D49BBCAB926BFC13 C872' +
'52C24E4C855CF602E9E1B72CDAFBB18E905E6C1AF73AE56E8 B56D' +
'FC4DD8BE500D336C231BA8E0375D9C7C0BB60BDB4B494E436 EF69' +
'6BF303B9F7C0A7BF804AE09816754E404F5972E6C2F9A5CE5 BC67' +
'BBFE7EF3EC395098F204B30F2924ACC4BA1EE11C75BC1774D 1CB9' +
'5EE486706EBB438B7B62B33F929CFC32F7EC92DFBE0910D5A E93B' +
'507FE7EF74517BD1E426339A5C33D76C20D5F05C12522BBAF 8D7B' +
'D80DF6446E7A4FE2CFE3BB467AC4454F08F7431CEDF49514D 8B59' +
'A196D9C9F74320D72BB166FB9A7FDCFFB5F942DE4BF809737 079D' +
'495A81252EB08B9E67F961CCDACEF33C5B6659E8F39CDA961 2E09' +
'B1E40DFF786646CC17DBBD5BC109F332E723C86D6E714B4D3 5F63' +
'D906BFEF1CC8C9B57B64F988BED13669AF3689861BB477E97 FFD2' +
'7C73B7C14ABC64D63B9E26AFCC9AFC5D7ECB5C6CDBB346D3F 6986' +
'BB68BEDC6F908FFEFE4E6C4B93EC13573DDFDCAAA7C8DFF9A D9EC' +
'D83DC33DF2BAFBE1AC01798FFF2572BBFB8DDF481BDB58952 0EFF' +
'09F98EF908FD8461D313C9413E776B7BF4CDEE1BFFB867542 8EDD' +
'BBA4A5CB3F9219BDCF982EF45BF3B8E1EBB7EF137E2407F75 86DF' +
'E66FE2DE7335A3DF5E9D34B4E53D10BBE0B746412F596D567 FCCF' +
'EABB56EFF2FF529F3DF70FB9DE4B0C');
end;

Procedure PaintForm(Sender : TObject);
begin
CopyCanvas(GetBitmapCanvas(BitMap), MainForm.Canvas, 0, 0, 29, 30, xpos, ypos, Width + xpos, Height + ypos);
end;


Procedure LoadForm;
Begin
MainForm := CreateForm;
MainForm.SetBounds(0, 0, 500, 400);
MainForm.POSITION:= poDesktopCenter;
MainForm.BORDERICONS:= [biMinimize, biSystemMenu];
MainForm.BORDERSTYLE:= bsSingle;
MainForm.Caption := 'Display Picture';
MainForm.Onpaint := @PaintForm;
MainForm.ShowModal;
end;

Procedure SafeLoadForm;
Var
V : TVariantArray;
begin
SetArrayLength(V, 0);
ThreadSafeCall('LoadForm', V);
end;


begin
try
LoadTheBitmap;
SafeLoadForm;
finally
FreeForm(MainForm);
FreeBitMap(Bitmap);
except
Writeln('ERROR');
end;
end.