473,804 Members | 2,292 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.EventArg s) Handles Button2.Click
Try
Me.PrntDoc_Img. PrinterSettings .PrinterName = "Canon MF3110"
Me.PrntDoc_Img. DocumentName = "Vitex Label"
AddHandler PrntDoc_Img.Pri ntPage, AddressOf Me.pd_PrintPage
PrntDoc_Img.Pri nt()
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(By Val sender As Object, ByVal ev As
System.Drawing. Printing.PrintP ageEventArgs)
' Draw a picture.
'ev.Graphics.
ev.Graphics.Dra wImage(Me.Pictu reBox1.Image, _
ev.Graphics.Vis ibleClipBounds)

' 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?

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

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

ev.Graphics.Dra wImage(Me.Pictu reBox1.Image,
ev.Graphics.Vis ibleClipBounds. 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
1882
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
6194
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 the DLL above. Now the application, together with the above DLL’s is successfully loading a TIF image file (62992 x 113386 Pixels, Huffman RLE compression, 3200 x 3200 DPI resolution, binary colored (1 Bit Per Pixel), file on disk size 43.08...
7
17492
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 upper left corner and a second x,y point defining the lower right corner. In VB6 the 0,0 location was the upper left like in GDI+, but I could at least reset it so I could use it with lat/lons. Basically all I want to do is be able to use the...
18
7445
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 them in my VB.NET app using the picturebox control. I was really happy when I learned that you could use PNG images in VB.NET so your images could blend in with the form's background color. But, is PNG the ideal image format to use with these...
6
2955
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 Application Project. I want to pass Image as one of the parameter but I figure that an Image doesn't have a handle. Previously I had it working in a Web Application Project using the handle of a PictureBox. Is there any workaround? Please help and...
3
63450
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 display (in the status bar) the image coordinates of the mouse location. However, if I use the picturebox's MouseMove event, I am getting the coordinates of the mouse over the PICTUREBOX, not the actual image underneath that (which is stretched)....
7
11647
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 is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an OpenFileDialog: Dim result As DialogResult = Pic_Sel.ShowDialog() If (result = DialogResult.OK) Then
1
7220
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 out on the jpg (change the picturebox size mode to zoom and scale the photo); 3. Move the jpg up, down, left right within a container control (using the MouseDown and MouseMove events, I change the location of the jpg); 4. Save the visible...
4
6470
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 comment on that ! Best regards Frank Uray
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.