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
 Copying to a bitmap from a TImageEnView

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
bmesser Posted - Nov 22 2012 : 06:03:43
Hi

I have a routine that takes the layers displayed in an TImageEnView component grabs a bitmap from the merged layer and adds it to my animated GIF. All works very well. What I want to do is grab a similar merged bitmap but from a zoomed TImageEnView component rather than the whole thing. I've tried to do this with CopyRectTo but without much luck, could someone point me at the correct method?

I've attached some pseudo code to give you an idea what works at the moment.

Bruce.

bmp : TBitMap;
iebmp : TIEBitMap;

for idx:=ImageEnView.LayersCount-1 downto 0 do
begin
  ImageEnView.LayersMergeTo(0,idx,iebmp);
  iebmp.CopyToTBitmap(bmp);
  iebmp.FreeImage;
  AddBitmapToAnimatedGIF(GIF,bmp,false); // routine to add to animated GIF
end;

1   L A T E S T    R E P L I E S    (Newest First)
w2m Posted - Nov 23 2012 : 13:58:26
procedure TFormMain.SaveAsGIF1Click(Sender: TObject);
// Create an animated gif from the layers in a TImageEnVect (TimageEnView) accounting for zoom
var
  i: integer;
  iFilename: string;
  iIEBitmap: TIEBitmap;
  iIndex: integer;
  iImageEnMView: TImageEnMView;
  iWidth: integer;
  iHeight: integer;
  iFrames: integer;
begin
  iFilename := 'anim.gif';
  // Create TImageEnMView to save the multiframe file
  iImageEnMView := TImageEnMView.Create(nil);
  try
    for i := 0 to ImageEnVect1.LayersCount - 1 do
    begin
      // Get the zoomed image dimensions-Get the width of the area used to show current image.
      iWidth := ImageEnVect1.ExtentX;
      // Get the height of the area used to show the current image.
      iHeight := ImageEnVect1.ExtentY;
      // Create the TIEBitmap to hold the image from a layer
      iIEBitmap := TIEBitmap.Create(iWidth, iHeight, ie24RGB);
      try
        // Copy the layers IEBitmap to iIEBitmap
        // This is a cropped and zoomed image which should be similar to the zoomed image on the screen
        ImageEnVect1.Layers[i].Bitmap.RenderToCanvasWithAlpha(iIEBitmap.Canvas, 0, 0, iWidth, iHeight, 0, 0, iWidth, iHeight,
          255, rfNone);
        // AppendImage appends a new image at last position in the list and returns the new image position
        iIndex := iImageEnMView.AppendImage;
        // Set the TIEBitmap to the iImageEnMView frame
        iImageEnMView.SetIEBitmap(iIndex, iIEBitmap);
        // Set the Gif's image index
        iImageEnMView.MIO.Params[i].GIF_ImageIndex := iIndex;
        // Free the Bitmap
        iImageEnMView.ReleaseBitmap(i);
      finally
        iIEBitmap.Free;
      end;
    end;
  // Save the animated multiframe GIF file.
  iImageEnMView.MIO.SaveToFileGIF(iFilename);
  finally;
    iImageEnMView.Free;
  end;
    iFrames := IEGetFileFramesCount(iFilename);
  MessageBox(0, PWideChar(IntToStr(iFrames) +
    ' frames were added to the GIF file and the file was saved as ' + iFilename + '.'), '',
    MB_ICONINFORMATION or MB_OK);
end;

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