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

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 SetExternalBitmap and Layers

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
egrobler Posted - Sep 24 2012 : 07:22:13
Hi

How can I update a layer when I attach a bitmap?

EcImageEnVect1.SetExternalBitmap(EcImageEnVect2.IEBitmap);

EcImageEnVect1.IO.LoadFromFile('background.jpg');
EcImageEnVect1.LayersAdd;
EcImageEnVect1.IO.LoadFromFile('layer.png');

EcImageEnVect2.Update; //Only background is visible on the second image

Best Regards
Eric
3   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Sep 24 2012 : 09:44:41
Where are you caling this?

Try this:

Open the ...Annotations\Vectorial Demo in the samples folder.
Add a button to the properties scrollbox located on the right side of the main form. Add a ImageEnView to Panel2 located on the left side of the main form. Set the AutoShrink property of the ImageEnView2 to true (ImageEnView2.AutoShrink := True). Then add the following code:
procedure TMainForm.LoadLayers1Click(Sender: TObject);
var
  iMS: TMemoryStream;
  iLayer: integer;
begin
  if OpenImageEnDialog1.Execute then
  begin
    ImageEnVect1.IO.LoadFromFile(OpenImageEnDialog1.FileName);
    ImageEnVect1.LayersSync := False;
    ImageEnVect1.CurrentLayer.VisibleBox := True;
    ImageEnVect1.CurrentLayer.Selectable := True;
    ImageEnVect1.LayersDrawBox := True;
  end;
  iLayer := ImageEnVect1.LayersAdd;
  if OpenImageEnDialog1.Execute then
    ImageEnVect1.IO.LoadFromFile(OpenImageEnDialog1.FileName);
    iMS := TMemoryStream.Create;
    try
      ImageEnVect1.LayersSaveToStream(iMS);
      iMS.Position := 0;
      ImageEnView2.LayersLoadFromStream(iMS);
      ImageEnView2.Update;
    finally
      iMS.Free;
    end;
  ImageEnVect1.LayersCurrent := iLayer;
  ImageEnVect1.MouseInteract := [miMoveLayers, miResizeLayers];
end;

procedure TMainForm.ImageEnVect1LayerNotify(Sender: TObject; layer: Integer; event: TIELayerEvent);
var
  iMS: TMemoryStream;
begin
  // If moving or resizing a layer update the preview ImageEnView
  if (event = ielMoving) or (event = ielResized) then
  begin
    iMS := TMemoryStream.Create;
    try
      ImageEnVect1.LayersSaveToStream(iMS);
      iMS.Position := 0;
      ImageEnView2.LayersLoadFromStream(iMS);
      ImageEnView2.Update;
    finally
      iMS.Free;
    end;
  end;
end;


Click the button then select a layer with the mouse and move it around. All the layers should appear in the ImageEnView (preview) and the layers should be updated when you move the layer in ImageEnVect.

This works with no exceptions or errors here. I have no idea why you get an exception.

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html
egrobler Posted - Sep 24 2012 : 08:15:39
Hi William,

I get an Invalid ZStream operation error when trying to save to the stream.
iMS := TMemoryStream.Create;
  try
    ImageEnVect1.IO.LoadFromFile('background.jpg');
    ImageEnVect1.LayersAdd;
    ImageEnVect1.IO.LoadFromFile('layer.png');

    ImageEnVect1.LayersSaveToStream(iMS); //Invalid ZStream operation
    iMS.Position := 0;

    ImageEnVect2.LayersLoadFromStream(iMS);
    ImageEnVect2.Update;
  finally
    iMS.Free;
  end;
w2m Posted - Sep 24 2012 : 08:00:00
Do not use SetExternalBitmap. Instead use a ImageEnView for the preview and set AutoShrink to true. Then do this:
var
iMS: TMemoryStream;
begin
  iMS := TMemoryStream.Create;
  try
    ImageEnView1.LayersSaveToStream(iMS);
    iMS.Position := 0;
    Preview1.LayersLoadFromStream(iMS);
    Preview1.Update;
  finally
    iMS.Free;
  end;
end;

William Miller
Adirondack Software & Graphics
Email: w2m@frontiernet.net
EBook: http://www.imageen.com/ebook/
Apprehend: http://www.frontiernet.net/~w2m/index.html