ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 IEBitmap.Modified
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

w2m

USA
1990 Posts

Posted - Apr 28 2016 :  11:37:00  Show Profile  Reply
I have found something I do not understand.

When ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB is called, ImageEnView1.IEBitmap.Modified is True. When ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB is called, ImageEnView1.IEBitmap.Modified is False.
Does anyone know why just getting the pixel color sets ImageEnView1.IEBitmap.Modified to True? Can anyone duplicate this problem?

iRGB := ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB[iX, iY];
{ Show the color under the cursor }
iColor := TRGB2TColor(iRGB);

iColor := ImageEnView1.Layers[0].Bitmap.Canvas.Pixels[iX, iY];

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development

xequte

39061 Posts

Posted - Apr 28 2016 :  23:45:38  Show Profile  Reply
Hi Bill

I can't reproduce this using the following code:

    MainForm.Caption := XBoolToStr( ImageEnView1.iebitmap.modified );
    iRGB := ImageEnView1.Layers[0].Bitmap.Pixels_ie24RGB[5, 5];
    MainForm.Caption := MainForm.Caption + '->' + XBoolToStr( ImageEnView1.iebitmap.modified );
    button1.font.Color := TRGB2TColor(iRGB);


It outputs
False->False


There's probably some color conversion going on. Try putting a break point on the SetModified and Changed events and see what triggers it.



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - Apr 29 2016 :  10:36:00  Show Profile  Reply
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
Go to Top of Page

xequte

39061 Posts

Posted - May 01 2016 :  20:04:02  Show Profile  Reply
Hi Bill

The next update will prevent the call to canvas "modifying" the TIEBitmap (except when tranformations are required).


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
Go to Top of Page

w2m

USA
1990 Posts

Posted - May 02 2016 :  12:35:33  Show Profile  Reply
Thanks Nigel.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: