ImageEn, unit imageenview |
|
TImageEnView.VisibleBitmapRect
Declaration
property VisibleBitmapRect : TRect; (read/write)
Description
Show a specific area of the current image, or return the area of the image that is shown.
Note: The rectangle passed will be automatically adjusted to ensure the correct aspect ratio.
// Show the central portion of an image
ImageEnView1.VisibleBitmapRect := Rect( 100, 100, 200, 200 );
// Output the visible bitmap in ImageEnView1 to ImageEnView2
ImageEnView2.IEBitmap.Width := IERectangle( ImageEnView1.VisibleBitmapRect ).Width;
ImageEnView2.IEBitmap.Height := IERectangle( ImageEnView1.VisibleBitmapRect ).Height;
ImageEnView1.IEBitmap.DrawToTIEBitmap( ImageEnView2.IEBitmap, 0, 0, IERectangle( ImageEnView1.VisibleBitmapRect ));
ImageEnView2.Update();
// Save the visible bitmap in ImageEnView1 to file
bmp := TIEBitmap.Create( IERectangle( ImageEnView1.VisibleBitmapRect ).Width, IERectangle( ImageEnView1.VisibleBitmapRect ).Height );
ImageEnView1.IEBitmap.DrawToTIEBitmap( bmp, 0, 0, IERectangle( ImageEnView1.VisibleBitmapRect ));
bmp.SaveToFile( 'D:\View.jpg' );
bmp.Free();
// Zoom into the selected area of the image
procedure TMainForm.Button1Click(Sender: TObject);
var
sel: TIERectangle;
begin
if ImageEnView1.Selected then
begin
sel := ImageEnView1.SelectedRect;
ImageEnView1.VisibleBitmapRect := Rect( sel.x, sel.y, sel.x + sel.width, sel.y + sel.height );
end;
end;
// Show Layer 1 completely filling the view
ImageEnView1.VisibleBitmapRect := ImageEnView1.Layers[1].LayerRect;
// Adjust view to show all layers
var
rect: TIERectangle;
begin
// Make IEView consider all layers when calculating image bounds
ImageEnView1.LayerOptions := ImageEnView1.LayerOptions + [loDynamicCanvas];
// Position layers so origin is 0,0
rect := ImageEnView1.LayersRect(False, True);
ImageEnView1.LayersRepositionAll(-rect.X, - rect.Y);
// Get updated layer rect and show it at size of control
rect := ImageEnView1.LayersRect(False, True);
ImageEnView1.VisibleBitmapRect := IERectangleToRect( rect );
end;
See Also
◼ViewX◼ViewY◼ExtentX◼ExtentY