[SOLVED] How to Assign a Bitmap to the BGRAGraphicControl lazarus / 39-Graphics ---------------------------------------------------------------------- pixelink · 2019-07-16 18:41 Hi, I am trying to assign a bitmap to the BGRAGraphicControl, but get an error saying I can't. Why? Here is my code Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,  BGRAGraphicControl, BGRABitmap, BGRABitmapTypes, BCTypes; type   { TForm1 }   TForm1 = class(TForm)    BGRAGraphicControl1: TBGRAGraphicControl;    Button1: TButton;    procedure BGRAGraphicControl1Paint(Sender: TObject);    procedure BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap);    procedure Button1Click(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private   public   end; var  Form1: TForm1;  TheImage : TBGRABitmap;  //TheImage : TBitmap; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin    TheImage := TBGRABitmap.Create('test.jpg');    BGRAGraphicControl1.width:=TheImage.width;    BGRAGraphicControl1.height:=TheImage.height;    BGRAGraphicControl1.Assign(TheImage); {<-- ERROR - Can't Assign image}     //TheImage := TBGRABitmap.Create;    //TheImage.LoadFromFile('test.jpg');    //TheImage.Canvas.FillRect(0,0,TheImage.Width,TheImage.Height);    //TheImage.SetSize(BGRAGraphicControl1.Width, BGRAGraphicControl1.Height);    //BGRAGraphicControl1.Canvas.Brush.Style:=bsClear;    //BGRAGraphicControl1.Canvas.Brush.Style:=bsClear; end; procedure TForm1.FormDestroy(Sender: TObject);begin  TheImage.Free;end; procedure TForm1.BGRAGraphicControl1Paint(Sender: TObject);begin  if assigned(TheImage) then  begin    TheImage.Draw(Canvas,0,0,false); //true makes it opaque - false makes transparent    //BGRAGraphicControl1.Canvas.Draw(0,0,true);   end; end; procedure TForm1.BGRAGraphicControl1Redraw(Sender: TObject; Bitmap: TBGRABitmap  );begin  //if assigned(TheImage) then     //TheImage.FillTransparentend; end. [\code] ---------------------------------------------------------------------- winni · 2019-07-16 19:52 TBGRAGraphicControl is a component that owns a TBGRABitmap - similar to TImage. So the correct assign for your example is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i BGRAGraphicControl1.Bitmap.Assign(TheImage);   Winni ---------------------------------------------------------------------- pixelink · 2019-07-16 21:56 Quote from: winni on July 16, 2019, 09:52:33 pmTBGRAGraphicControl is a component that owns a TBGRABitmap - similar to TImage. So the correct assign for your example is Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i BGRAGraphicControl1.Bitmap.Assign(TheImage);   Winni Perfect! I was missing just one word.