Forum > Graphics
Assigning a TBitmap to a TBitmap32
niotronic:
Hi,
I'm using the TImage32, which is part of the graphics32 library and I'm trying to assign a TBitmap to the TImage32.Bitmap, which always results in a totally black screen. On the canvas of the TBitmap32 (=TImage32.Bitmap) however I can draw lines and fill rects without problems. If I assign the TBitmap to a TImage.Bitmap (the standard TImage) the bitmap contained in the original Bitmap is shown correctly. So it's obviously a problem with the TImage32.Bitmap not accepting the standard TBitmap contents ?
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- FImage:=TImage32.Create(self);FImage.Parent:=self;FImage.Align:=alClient;FImage.Scale:=1; FImage.Bitmap.Assign(Bitmap); //shows up as a black screenFImage.Bitmap.LoadFromFile('/home/arm1/Dokumente/Linux NIO Analyzer V2-90 - FPC/Graphics/TDIBackground.bmp'); //also shows up as a black screenFImage.Bitmap.Changed; FImage.Bitmap.Clear(cllime); //this is shown correctlyFImage.Bitmap.Line(0, 0, 150, 150, clblack, TRUE); //shown correctly
Any ideas, what might cause the TImage32 to show any Bitmap assigned as a black screen ?
Best regards
KL
winni:
Hi!
a)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---FImage.LoadFromFile('/home/....');
b)
There are a lot of examples in
--- Code: Text [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---ct4laz/pl_examples/pl_graphics32/
Winni
niotronic:
Dear Winni,
your suggestion a) is unfortunately not applicable for me since I'm loading the image out of a database via a TStream.
The same code works pretty fine on DELPHI, but when I compile on Lazarus, the TImage32 always shows a black screen after a calling:
FImage.Assign(MyBitmap);
When I for test purposes only assign MyBitmap to a standard TImage it correctly shows the contents of MyBitmap, which prooves that MyBitmap contains correct data.
On the otherhand I can draw on the TImage32 canvas whatever I want and it shows it correctly.
So the problem must be anywhere in the
FImage.Assign(myBitmap) which obviously cannot deal with the data contained in Mybitmap.
Just to remember: This is working pretty fine on DELPHI...
I'm using Lazarus 1.8.4 and the graphics32 version is 1.9
Any call of FImage.Changed, FImage.ForceFullInvalidate etc. doesn't make it show the contents of MyBitmap...
Best regards,
KL
engkin:
The following code works correctly here:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.Button1Click(Sender: TObject);var FImage: TImage32; Bitmap: TBitmap;begin FImage:=TImage32.Create(self); FImage.Parent:=self; FImage.Align:=alClient; FImage.Scale:=1; Bitmap := TBitmap.Create; Bitmap.LoadFromFile('c:\Path\To\Some.bmp'); FImage.Bitmap.Assign(Bitmap); //Works
I am using Win32, Laz2.0.10, GR32 2.0
niotronic:
I tried now to use the latest version of Lazarus (2.1) and of the graphics32 (V1.9 fixed) but unfortunately there hasn't anything changed.
Calling the Assign procedure of TImage32 with a TBitmap as Parameter still results in a black screen - However directly drawing on the Bitmap of the TImage32 works perfectly.
I wrote a small test program which shows this problem...
The whole project is attached.
Attached are also screenshots, one them shows the black screen after pressing "Assign bitmap" - The standard TImage shows the picture correctly, the TImage32 only shows a black screen.
The results of clicking on "Draw on TImage32.Bitmap" is shown in the second picture...
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, GR32_Image, ExtCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; Button2: TButton; Image1: TImage; Panel1: TPanel; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private FImage32: TImage32; public end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var ABitmap: TBitmap;beginABitmap:=TBitmap.create;tryABitmap.LoadFromFile('/home/arm1/Downloads/Floorplan2.bmp');FImage32.Bitmap.Assign(ABitmap);Image1.Picture.Bitmap.Assign(ABitmap);finally ABitmap.Free;end; //FImage32.Bitmap.LoadFromFile('/home/arm1/Downloads/Floorplan2.bmp'); end; procedure TForm1.Button2Click(Sender: TObject);begin FImage32.Bitmap.Clear(cllime); FImage32.Bitmap.Line(10, 10, 200, 200, clblack); FImage32.Bitmap.FillRect(140, 40, 180, 80, clblue);end; procedure TForm1.FormCreate(Sender: TObject);begin FImage32:=TImage32.Create(self); FImage32.Align:=alClient; FImage32.Parent:=self;end; procedure TForm1.FormDestroy(Sender: TObject);begin FImage32.Free;end; end.
Navigation
[0] Message Index
[#] Next page