Bitmap raw data access in Mac OS X / Cocoa lazarus / 39-Graphics ---------------------------------------------------------------------- agorka · 2018-06-26 12:42 Hello! I have an lazarus app that runs fine on OS X + Carbon, but since carbon is going to be deprecated in the next OS X release, I 'm trying to switch to Cocoa Widgetset. I'm stuck with direct pixels access. The code that worked in Carbon doesn't work anymore, RawImage.Data is just returning all zeroes. I made a small testing procedure: 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 procedure TForm1.TestBitmaps;var Bmp : TBitmap;beginBmp:=TBitmap.Create;Bmp.Widt h:=32;Bmp.Height:=32;Bmp.PixelFormat:=pf32bit;Bmp.Canvas.Pixels[0,0]:= $123456;ShowMessage(ColorToString(Bmp.Canvas.Pixels[0,0]));Bmp.BeginUp date();Bmp.EndUpdate();ShowMessage(ColorToString(Bmp.Canvas.Pixels[0,0 ]));Bmp.Free;end;    First message shows $00123456, but after calling BeginUpdate / EndUpdate, second message shows $00000000, so Begin/EndUpdate seem to vipe all the bitmap data. I tried using LazIntfImage to access pixels, but once again I'm getting zeroes instead of real color values. Can anyone help me with that? I'm using Lazarus 1.8.4/FPC3.0.4 Thanks in advance! ---------------------------------------------------------------------- BeanzMaster · 2018-06-26 13:10 Hi, Graphics with FCL/LCL are heavy buggy in all OS, like i said in the topic on my TGIFViewer component. It need to be rework. In waiting i suggest you try to BGRABitmap instead is very very more stable, and pretty is pretty cool.  I you can post this issue in the bugtracker ---------------------------------------------------------------------- wp · 2018-06-26 13:27 I tested on Windows and see the same - clBlack after the Bitmap.EndUpdate. What do you want to achieve with BeginUpdate/EndUpdate? Investigating the sources I found that they are used when a TRawImage (an ancestor of TBitmap) is loaded from a stream or another image. Is it that what you want to do? Looking at the declaration of BeginUpdate I see an optional boolean parameter ACanvasOnly which defaults to False. After setting this to true (Bitmap.BeginUpdate(true)) the set color is indicated also by the second ShowMessage. 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 type  TRasterImage = class(TGraphic)  // TRasterImage is ancestor of TBitmap  ...    procedure BeginUpdate(ACanvasOnly: Boolean = False);  procedure EndUpdate(AStreamIsValid: Boolean = False);  ...end; ---------------------------------------------------------------------- agorka · 2018-06-26 13:42 Thanks for answering! I made more complex test function: 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 procedure TForm1.TestBitmaps;var Bmp : TBitmap;    LazIntfImage : TLazIntfImage; beginBmp:=TBitmap.Create;Bmp.Width:=32;Bmp.Height:=32;Bmp.PixelFormat: =pf32bit;Bmp.Canvas.Brush.Color:=$234567;Bmp.Canvas.FillRect(0,0,32,32 );LazIntfImage:=Bmp.CreateIntfImage;ShowMessage(ColorToString(Bmp.Canv as.Pixels[0,0])+'- LazIntf.Colors:'+IntToStr(LazIntfImage.Colors[0,0].green)+          '- LazIntf.PixelData:'+IntToStr(LazIntfImage.PixelData[1]));Bmp.BeginUpda te(True);ShowMessage(ColorToString(Bmp.Canvas.Pixels[0,0])+'- Raw:'+IntToStr(Bmp.RawImage.Data[1]));Bmp.EndUpdate(False);ShowMessage (ColorToString(Bmp.Canvas.Pixels[0,0]));Bmp.Free;end;   On Cocoa I get: $00234567-LazIntf.Colors:0-LazIntf.PixelData:0 $00234567-Raw:0 $00234567 On Carbon the same code gives: $00234567-LazIntf.Colors:17733-LazIntf.PixelData:103 $00234567-Raw:103 $00234567 So probably this problem is not caused by BeginUpdate wiping data but by some raw pixel data copying to RawImage.Data. Oleg.