Gets or sets the rectangle that specifies the portion of the image to print.
Syntax
Visual Basic (Declaration) | |
---|
Public Property ImageRectangle As Rectangle |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As RasterImagePrinter
Dim value As Rectangle
instance.ImageRectangle = value
value = instance.ImageRectangle
|
C# | |
---|
public Rectangle ImageRectangle {get; set;} |
Managed Extensions for C++ | |
---|
public: __property Rectangle get_ImageRectangle();
public: __property void set_ImageRectangle(
Rectangle value
); |
Return Value
A
Rectangle that specifies the portion of the image to print.
Example
This example loads an image and then prints the top-left corner
of the image to the bottom-right corner of the page.
Visual Basic | Copy Code |
---|
Public imageToPrint As RasterImage = Nothing
Public Sub RasterImagePrinter_ImageRectangle()
RasterCodecs.Startup()
Dim codecs As RasterCodecs = New RasterCodecs()
imageToPrint = codecs.Load("C:\program files\LEAD Technologies\LEADTOOLS 15\Images\sample1.cmp")
RasterCodecs.Shutdown()
If Not PrinterSettings.InstalledPrinters Is Nothing AndAlso PrinterSettings.InstalledPrinters.Count > 0 Then
Dim printDocument As PrintDocument = New PrintDocument()
AddHandler printDocument.PrintPage, AddressOf pd_PrintPage
printDocument.Print()
End If
imageToPrint.Dispose()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs)
Dim printer As RasterImagePrinter = New RasterImagePrinter()
printer.SizeMode = RasterPaintSizeMode.Stretch
printer.HorizontalAlignMode = RasterPaintAlignMode.Center
printer.VerticalAlignMode = RasterPaintAlignMode.Center
Dim rc As Rectangle = New Rectangle(0, 0, imageToPrint.Width \ 2, imageToPrint.Height \ 2)
rc = imageToPrint.RectangleToImage(RasterViewPerspective.TopLeft, rc)
printer.ImageRectangle = rc
Dim pageWidth As Single = e.MarginBounds.Width / 2.0F
Dim pageHeight As Single = e.MarginBounds.Height / 2.0F
printer.PageRectangle = New RectangleF(pageWidth, pageHeight, pageWidth, pageHeight)
printer.Print(imageToPrint, imageToPrint.Page, e)
End Sub |
C# | Copy Code |
---|
public RasterImage imageToPrint = null; public void RasterImagePrinter_ImageRectangle() { // load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); imageToPrint = codecs.Load(@"C:\program files\LEAD Technologies\LEADTOOLS 15\Images\sample1.cmp"); RasterCodecs.Shutdown(); if(PrinterSettings.InstalledPrinters != null && PrinterSettings.InstalledPrinters.Count > 0) { PrintDocument printDocument = new PrintDocument(); printDocument.PrintPage += new PrintPageEventHandler(pd_PrintPage); printDocument.Print(); } // dispose the image imageToPrint.Dispose(); } private void pd_PrintPage(object sender, PrintPageEventArgs e) { // initialize a new RasterImagePrinter object RasterImagePrinter printer = new RasterImagePrinter(); // Use stretch so we fill out the page rectangle printer.SizeMode = RasterPaintSizeMode.Stretch; printer.HorizontalAlignMode = RasterPaintAlignMode.Center; printer.VerticalAlignMode = RasterPaintAlignMode.Center; // print the top-left quarter corner portion of the image Rectangle rc = new Rectangle(0, 0, imageToPrint.Width / 2, imageToPrint.Height / 2); rc = imageToPrint.RectangleToImage(RasterViewPerspective.TopLeft, rc); printer.ImageRectangle = rc; // print to the bottom-right corner of the image float pageWidth = e.MarginBounds.Width / 2F; float pageHeight = e.MarginBounds.Height / 2F; printer.PageRectangle = new RectangleF(pageWidth, pageHeight, pageWidth, pageHeight); // print the image printer.Print(imageToPrint, imageToPrint.Page, e); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also