Hi!
I am drawing a bitmap on TeeChart in FireMonkey for Windows:
var FBitmap: FMX.Graphics.TBitmap;
...
ParentChart.Canvas.StretchDraw(Rf,FBitmap)
...
The bitmap gets drawn, but the FBitmap.PixelFormat Property is ignored. The bitmap is drawn in the CMYK color mode it seems. (At least those are the colors I get to see). How can I get 4 byte RGB color format Bitmap displayed by TeeChart property?
Specifically:
TPixelFormat.pfA8R8G8B8;
Second: What to do to make the same code work on iOS, Android and OSx.
Thanks!
Atmapuri
Drawing bitmap on Windows
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Drawing bitmap on Windows
Hi Atmapuri,
We need to investigate this thoroughly. TeeChart only calls Firemonkey's:
New Chart1.Canvas.StretchQuality property controlls last parameter at the signature above. At Quality Central there are several open bugs aboug DrawBitmap.
Could you please attach a simple example project we can run "as-is" to reproduce the problem here?
We need to investigate this thoroughly. TeeChart only calls Firemonkey's:
Code: Select all
FCanvas.DrawBitmap(Graphic,TeeRect(0,0,Graphic.Width,Graphic.Height),
ARect,Opacity,FStretchQuality=sqLow);
Could you please attach a simple example project we can run "as-is" to reproduce the problem here?
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: Drawing bitmap on Windows
Dear Narcis,
Any example would do fine, where you can do:
bitmap.Size(2,2);
bitmap.Map(...,bitData);
...
P := bitData.Scanline[0];
P[0].A := 12;
P[0].R := 25;
P[0].G := 36;
P[0].B := 50;
P[1]...
bitmap.Unmap(...);
tChart.Canvas.StretchDraw(bitmap, tChart.ClientRect);
Thanks!
Atmapuri
Any example would do fine, where you can do:
bitmap.Size(2,2);
bitmap.Map(...,bitData);
...
P := bitData.Scanline[0];
P[0].A := 12;
P[0].R := 25;
P[0].G := 36;
P[0].B := 50;
P[1]...
bitmap.Unmap(...);
tChart.Canvas.StretchDraw(bitmap, tChart.ClientRect);
Thanks!
Atmapuri
-
- Site Admin
- Posts: 83
- Joined: Wed Nov 12, 2003 5:00 am
- Location: Girona, Catalonia
- Contact:
Re: Drawing bitmap on Windows
Hi Atmapuri
Just did the attached test project and it looks fine to me (both with high and low stretch blending modes).
regards
david
Just did the attached test project and it looks fine to me (both with high and low stretch blending modes).
regards
david
- Attachments
-
- StretchBitmap.zip
- (4.49 KiB) Downloaded 1745 times
Re: Drawing bitmap on Windows
Dear David,
Thank you for the example. However, in the question there is specifically mentioned the Scanline. I cannot use SetPixel, because it is orders of magnitude too slow.
Do you always use SetPixel with FireMonkey? That would mean that you have not figured out how to work with Scanline yet either?
Thanks!
Atmapuri
Thank you for the example. However, in the question there is specifically mentioned the Scanline. I cannot use SetPixel, because it is orders of magnitude too slow.
Do you always use SetPixel with FireMonkey? That would mean that you have not figured out how to work with Scanline yet either?
Thanks!
Atmapuri
-
- Site Admin
- Posts: 83
- Joined: Wed Nov 12, 2003 5:00 am
- Location: Girona, Catalonia
- Contact:
Re: Drawing bitmap on Windows
There are several usages of ScanLine already in FireMonkey TTeeCanvas, of course.
I've changed the example using scanline, same (ok) results, see below.
TeeCanvas StretchDraw simply passes the bitmap to FireMonkey's DrawBitmap method, there is nothing changed:
procedure TTeeCanvas3D.StretchDraw(const ARect: TRect; const Graphic: TGraphic);
begin
FCanvas.DrawBitmap(Graphic,TeeRect(0,0,Graphic.Width,Graphic.Height),
ARect,Opacity,FStretchQuality=sqLow);
end;
regards
david
...
var P : PAlphaColorArray;
...
b:=TBitmap.Create(2,2);
if b.Map(TMapAccess.maWrite,tmp) then
try
P:=tmp.GetScanline(0);
P[0]:=TAlphaColors.Red;
P[1]:=TAlphaColors.Green;
P:=tmp.GetScanline(1);
P[0]:=TAlphaColors.Blue;
P[1]:=TAlphaColors.Yellow;
{
tmp.SetPixel(0,0,TAlphaColors.Red);
tmp.SetPixel(0,1,TAlphaColors.Green);
tmp.SetPixel(1,0,TAlphaColors.Blue);
tmp.SetPixel(1,1,TAlphaColors.Yellow);
}
finally
b.Unmap(tmp);
end;
Chart1.DelphiCanvas.BeginScene;
Chart1.Canvas.StretchDraw(Chart1.AbsoluteRect,b);
Chart1.DelphiCanvas.EndScene;
I've changed the example using scanline, same (ok) results, see below.
TeeCanvas StretchDraw simply passes the bitmap to FireMonkey's DrawBitmap method, there is nothing changed:
procedure TTeeCanvas3D.StretchDraw(const ARect: TRect; const Graphic: TGraphic);
begin
FCanvas.DrawBitmap(Graphic,TeeRect(0,0,Graphic.Width,Graphic.Height),
ARect,Opacity,FStretchQuality=sqLow);
end;
regards
david
...
var P : PAlphaColorArray;
...
b:=TBitmap.Create(2,2);
if b.Map(TMapAccess.maWrite,tmp) then
try
P:=tmp.GetScanline(0);
P[0]:=TAlphaColors.Red;
P[1]:=TAlphaColors.Green;
P:=tmp.GetScanline(1);
P[0]:=TAlphaColors.Blue;
P[1]:=TAlphaColors.Yellow;
{
tmp.SetPixel(0,0,TAlphaColors.Red);
tmp.SetPixel(0,1,TAlphaColors.Green);
tmp.SetPixel(1,0,TAlphaColors.Blue);
tmp.SetPixel(1,1,TAlphaColors.Yellow);
}
finally
b.Unmap(tmp);
end;
Chart1.DelphiCanvas.BeginScene;
Chart1.Canvas.StretchDraw(Chart1.AbsoluteRect,b);
Chart1.DelphiCanvas.EndScene;
Re: Drawing bitmap on Windows
Hello David,
The problem was resolved after I learned that:
1.) The Alpha field in RGB needs to be set to $FF (not transparent).
2.) The structure for the color has reversed storage format, Instead of RGB for VCL (24bit), it is ABGR for Firemonkey. (32 bit)
Because I was constructing colors from scratch I lost my compass for a while.
It took some time to make the code work with Alpha values of each color set to $FF.
Thanks for the assistance.
Kind Regards!
Atmapuri
The problem was resolved after I learned that:
1.) The Alpha field in RGB needs to be set to $FF (not transparent).
2.) The structure for the color has reversed storage format, Instead of RGB for VCL (24bit), it is ABGR for Firemonkey. (32 bit)
Because I was constructing colors from scratch I lost my compass for a while.
It took some time to make the code work with Alpha values of each color set to $FF.
Thanks for the assistance.
Kind Regards!
Atmapuri