Devis Posted June 27, 2012 Share Posted June 27, 2012 (edited) Is it possible to load a Bitmap from string within a form. For example if i wanted to load a banner on a form, instead of defining the path for the picture file, could I use a string? BannerImg := TImage.Create(FrmDesign); BannerImg.Parent := FrmDesign; BannerImg.Left := 0; BannerImg.Top := 0; BannerImg.Width := 798; BannerImg.Height := 196; b := loadbitmap('C:\Users\ MYBMP.bmp'); getbitmapsize(b, w, h); copycanvas(getbitmapcanvas(b), BannerImg.canvas, 0, 0, w, h, 0, 0, w, h); So instead of defining: b := loadbitmap('C:\Users\ MYBMP.bmp'); Can i use something like this? b := loadbitmap(Banner); and load it as a string at the top of my script.. like this.. procedure LoadBmps; begin Banner := BitmapFromString(336, 25, ' STRING HERE + +STRING HERE); end; Thanks Devis. Edited June 27, 2012 by Devis Quote Link to comment Share on other sites More sharing options...
LordJashin Posted June 27, 2012 Share Posted June 27, 2012 (edited) I have no idea, you could try to do it and then display the component some where to test it. But, the TBitmap component in SCAR Divi is broke AFAIK. Also there is far less functions/procedures in those components then in Delphi. You could try passing the handle, and other things around. SCAR Divi has its own Bitmap Resource Management system. You could try using LoadFromFile. Just don't forget to free your bitmaps. One thing you could do though. Load the bitmap from a string. Then DRAW it on the canvas of the Form Component. Using FastDraw or other SCAR bitmap drawing functions. The X, Y is point on the bitmap to draw your bitmap to. Another thing that needs documentation. The functions with "Fast" in front of them are very useful for bitmaps in SCAR Divi. Edited June 27, 2012 by LordJashin Quote Link to comment Share on other sites More sharing options...
shadowrecon Posted June 27, 2012 Share Posted June 27, 2012 you need to use SafeCopyCanvas [scar] var Form1: TForm; Image1: TImage; procedure CopyBitmapToCanvas; var BMP: Integer; begin //BMP := BitmapFromString(20, 20, ''); BMP := CreateBitmap(30, 30, clBlack); SafeDrawBitmap(BMP, Image1.Canvas, 0, 0); FreeBitmap(BMP); end; procedure Form1_Init; begin Form1 := CreateForm; Image1 := TImage.Create(Form1); with Form1 do begin Left := 376; Top := 174; Caption := 'Form1'; ClientHeight := 202; ClientWidth := 304; Color := clBtnFace; Font.Charset := DEFAULT_CHARSET; Font.Color := clWindowText; Font.Height := -11; Font.Name := 'Tahoma'; Font.Style := []; OldCreateOrder := False; PixelsPerInch := 96; end; with Image1 do begin Parent := Form1; Left := 64; Top := 28; Width := 176; Height := 156; end; CopyBitmapToCanvas; end; procedure Form1_SafeInit; var v: TVariantArray; begin SetLength(v, 0); ThreadSafeCall('Form1_Init', v); end; function Form1_ShowModal: Boolean; begin Result := Form1.ShowModal = mrOk; end; function Form1_SafeShowModal: Boolean; var v: TVariantArray; begin SetLength(v, 0); Result := ThreadSafeCall('Form1_ShowModal', v); end; begin Form1_SafeInit; if Form1_SafeShowModal then WriteLn('Form returned modalresult ok'); FreeForm(Form1); end. [/scar] Quote Link to comment Share on other sites More sharing options...