473,501 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to print an image in Picturebox control as its scale

I have an Image in a picture box in VS 2005 that I want to print using
the following event handlers:

Private Sub btnPrintLabels_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Button2.Click
Try
Me.PrntDoc_Img.PrinterSettings.PrinterName = "Canon MF3110"
Me.PrntDoc_Img.DocumentName = "Vitex Label"
AddHandler PrntDoc_Img.PrintPage, AddressOf Me.pd_PrintPage
PrntDoc_Img.Print()
Catch ex As Exception
MessageBox.Show("An error occurred while printing", _
ex.ToString())
End Try

End Sub
' Specifies what happens when the PrintPage event is raised.
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As
System.Drawing.Printing.PrintPageEventArgs)
' Draw a picture.
'ev.Graphics.
ev.Graphics.DrawImage(Me.PictureBox1.Image, _
ev.Graphics.VisibleClipBounds)

' Indicate that this is the last page to print.
ev.HasMorePages = False
End Sub

Problem is that is prints the image on a scale of "filling" the whole
81/.2 by 11 document
Not the scale of the image
How can I change that?

PrintPageEventArgs.Graphics class may be what I want but I dont konw
for sure.
Any ideas?

Mar 8 '06 #1
3 8410
Instead of using the DrawImage(Image, Rectangle) overload, why not just
use the DrawImage(Image, Point) overload? Like this:

ev.Graphics.DrawImage(Me.PictureBox1.Image,
ev.Graphics.VisibleClipBounds.Location);

?

Mar 9 '06 #2
Thank you that worked. I will have to read up on what the difference is
between what you suggested and what I was using before other then
setting where the upper left corner will be.

Obviously that does something to set the scale of the image and the
bounds also.

Mar 9 '06 #3
If you specify a Rectangle, which is an upper-left corner, a width, and
a height, then DrawImage reshapes the image to fit the rectangle.

If you just specify a Point, then DrawImage assumes that you want the
image at its original size.

Mar 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1859
by: timm.wong | last post by:
Hi, I have a program where I load images to a screen. How would I go about determining the size of an image prior to loading it on the screen? Thanks, Tim
12
6162
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
7
17400
by: Randy Vande Hei | last post by:
Does anyone know how to change the the GDI+ coordinate system like you used to be able to do in VB6 with the picturebox.scale method. The picturebox.scale method took an x,y point defining the...
18
7414
by: Andrew Christiansen | last post by:
Hey all. The images I create in photoshop with semi-transparent pixels (for instance in Photoshop text with a dropshadow with a transparent canvas) I've been saving in PNG format and then using...
6
2934
by: anonymous | last post by:
hi all, I'm trying to use the capCreateCaptureWindow (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_capcreatecapturewindow.asp) in a Windows...
3
63292
by: Tom | last post by:
I have a picturebox on my VB.NET form. The picturebox size mode is set to stretched. I then load an image into that form and display it. As the user moves the mouse over the form, I want to get and...
7
11599
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
1
7196
by: DMCD | last post by:
I want to allow my program users to: 1. Open a jpg inside of a panel control (PictureBox control inside Panel control ... PictureBox picture set to user's jpg file selection); 2. Zoom in and...
4
6454
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I need to do a image viewer, just to view and zoom pictures in jpeg. I do not need to edit or save the picture. I am sure, there are some controls already made. I am thankful for any...
0
7164
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7046
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7232
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7272
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7424
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4958
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3125
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
331
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.