473,395 Members | 1,335 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Printing PNG file or any image file

Wondering if it is possible to send a xxx.PNG file directly to a printer without having to load it into a windows form, picturebox, ect... If so how do you do it

Thanks in advance
Kent
Nov 20 '05 #1
4 7324
"Kent" <kl*******@pentaxvision.com> schrieb
Wondering if it is possible to send a xxx.PNG file directly to a
printer without having to load it into a windows form, picturebox,
ect... If so how do you do it?

1. System.Drawing.Image.FromFile
2.
http://msdn.microsoft.com/library/de...intSupport.asp
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2
* "=?Utf-8?B?S2VudA==?=" <kl*******@pentaxvision.com> scripsit:
Wondering if it is possible to send a xxx.PNG file directly to a
printer without having to load it into a windows form, picturebox,
ect... If so how do you do it?


See 'PrintDocument' class, its 'PrintPage' event. There you can simply
use code like this:

\\\
Dim bmp As Image = Image.FromFile(...)
e.Graphics.DrawImage(bmp, ...)
bmp.Dispose()
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
PrintDocument1.Print()
End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object,
ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles
PrintDocument1.PrintPage
Dim g As Graphics = e.Graphics

g.DrawImage(Image.FromFile("C:\camera.bmp"), 5, 5)
End Sub

Ken
---------------
"Kent" <kl*******@pentaxvision.com> wrote in message
news:D4**********************************@microsof t.com...
Wondering if it is possible to send a xxx.PNG file directly to a printer
without having to load it into a windows form, picturebox, ect... If so
how do you do it?

Thanks in advance,
Kent

Nov 20 '05 #4
Thanks everyone for suggestions. This is what I came up with. Although the e.graphics.FromImage throws an exception it does still print to my printer.

The exception is: "a graphics object cannot be created from an image that has an indexed pixel format

As you can see I'm not handling the exception, any suggestions would be greatly appreciated

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clic
PrintDocument1.Print(
End Su

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPag
Dim objObject As Objec
Dim objBMP As Bitma

Tr
' Load the image
objObject = Image.FromFile("C:\xmltest\Label.png"
objBMP = objObject.Clon

Dim myimage = objBMP.Clon

e.Graphics.FromImage(myimage) <--Exception thrown her
Catch ex As Exceptio

Finall
e.Graphics.Dispose(
objObject.dispose(
objObject = Nothin
End Tr

End Su

Thanks again
Kent
Nov 20 '05 #5

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

Similar topics

4
by: Jody Gelowitz | last post by:
I am having a problem with printing selected pages. Actually, the problem isn't with printing selected pages as it is more to do with having blank pages print for those pages that have not been...
0
by: JF Turcotte | last post by:
Hi I'm unsuccessfully trying to print a form's image under VB.NET. To print under .NET is a real pain in the , I find it to be complex, lenghty, confusing, upsetting and ultimately not to be...
5
by: VMI | last post by:
I have a BMP image (the form is also in PDF) that contains a scanned copy of a paper form that we need to fill out. Is it possible to use this image in my application so that the application can...
0
by: lubprog | last post by:
hi, I am printing jpg files which are on a disk. The file name is selected from a database and the file is located on the disk and then printed. I am able to print the file but it takes a long...
3
by: D Witherspoon | last post by:
No matter what I do the default paper size is always either A3 or 11 by 8.5 .. Here is the code. Dim dlg As DialogResult pd.DocumentName = "Weld Image" Dim pkPaperSize As New...
1
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
4
by: Michele | last post by:
I use the code at the of this message to add a copyright text ( watermark ) on image printing. I would like to have a text Opacity at 30%. On print preview and normal view all is ok , but when I...
4
by: Prakash | last post by:
I'm developing an HR package which would contain the Employees Photo + upto 3 pages (pictures) of his Passport + pictures of his Driving License and Residence Card. If the user wants to print...
0
by: njdude | last post by:
Im trying to print a tif file with size 975x839 with resolution 300x300. Im printing this onto a virtual printer which takes a size of 1720x2200 200x196 dpi. Im using the following code ...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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
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...
0
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...

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.