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
 Functionality searched
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

PStadler

Austria
60 Posts

Posted - Jul 18 2011 :  22:57:38  Show Profile  Reply
Hello
In an image database, to avoid multiple copies of the same image, I would need the following functionality:

These images have many details, which should be visible separately. I would like to have the possibility to zoom a rectangular part of the image. Maybe this could be achieved by defining a rectangular part of the image with help of annotations. But if I show thumbnails in an ImageNMView, also only those rectangular sectors should be seen in the thumbnails. I want this without cutting it out from the original image.
What would be the best way to achieve such functionality?

Any ideas appreciated!
Sincerely
Peter

fab

1310 Posts

Posted - Jul 19 2011 :  14:37:30  Show Profile  Reply
Please look this code. It uses the event OnImageIDRequestEx of TImageEnMView to show a thumbnail only when requested.
Actually the requested rectangle is copied two times from the main image (one in the shared object MyBitmap and one inside TImageEnMView), but only when it needs to be displayed. Non-visible thumbnails aren't copied at all.
There aren't other ways using TImageEnMView.


// declare a global TIEBitmap object that will be used in ImageEnMView1ImageIDRequestEx
var MyBitmap:TIEBitmap;

// subrectangles of "image.jpg" to show
const subrects:array [0..3] of TIERectangle = (
  (x:0;   y:0;   width:100; height:100),
  (x:120; y:200; width:80;  height:200),
  (x:0;   y:220; width:300; height:70),
  (x:0;   y:400; width:300; height:70)
);

// Load "image.jpg" and add rectangles defined in "subrects"
procedure TForm1.Button22Click(Sender: TObject);
var
  i:integer;
begin
  MyBitmap := TIEBitmap.Create(); // remember to Free!!
  imageenview1.io.loadfromfile('hongkong.jpg');
  for i:=0 to high(subrects) do
    ImageEnMView1.ImageID[ ImageEnMView1.AppendImage() ] := i;
end;

// copy the requested rectangle when necessary
procedure TForm1.ImageEnMView1ImageIDRequestEx(Sender: TObject; ID: Integer; var Bitmap: TIEBitmap);
begin
  Bitmap := MyBitmap;
  Bitmap.Allocate(subrects[ID].width, subrects[ID].height);
  ImageEnView1.IEBitmap.CopyRectTo(Bitmap, subrects[ID].x, subrects[ID].y, 0, 0, subrects[ID].width, subrects[ID].height);
end;

Go to Top of Page

PStadler

Austria
60 Posts

Posted - Jul 19 2011 :  23:19:48  Show Profile  Reply
Hello Fabrizio,

Thanks a lot. I'll give it a try!

Sincerely

Peter
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: