Your code is incorrect. Modified is not changed when Bitmap.Pixels[iX, iY] or
ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB is called. It is changed when Bitmap.Canvas.Pixels is called. I can not establish why modified is set to true when Bitmap.Canvas.Pixels is executed but it maybe due to the creation of the canvas Font, Pen or Brush:
procedure TCanvas.RequiredState(ReqState: TCanvasState);
var
NeededState: TCanvasState;
begin
NeededState := ReqState - State;
if NeededState <> [] then
begin
if csHandleValid in NeededState then
begin
CreateHandle;
if FHandle = 0 then
raise EInvalidOperation.CreateRes({$IFNDEF CLR}@{$ENDIF}SNoCanvasHandle);
end;
if csFontValid in NeededState then CreateFont;
if csPenValid in NeededState then CreatePen;
if csBrushValid in NeededState then CreateBrush;
State := State + NeededState;
end;
end;
if UseCanvas1.Checked then
iColor := ImageEnView1.Layers[0].Bitmap.Canvas.Pixels[iX, iY]
else
begin
iRGB := ImageEnView1.Layers[0].Bitmap.Pixels[iX, iY];
// iRGB := ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB[ix, iY];
iColor := TRGB2TColor(iRGB);
end;
I created a simple demo for you to look at this. You may download it here:
attach/w2m/2016429103444_SetModified.zip
60.66 KB
If the Use Canvas Checkbox is Checked you will see that modified is set to true.
Although this is not a big problem because IEBitmap.Pixels can be used that does not set the modified property, often it is difficult to debug why the modified property is changed when nothing in a project actually changes the IEBitmap. Developers should be made aware that this does occur so they use the best way to get the color of a pixel- IEBitmap.Pixels.
Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development