Solved

How to print a Windows Bitmap file ?

Posted on 2000-04-03
8
312 Views
Last Modified: 2013-12-03
I'd like to send Windows Bitmap files to a printer.
Would it be possible to perform that task using PCL commands ?  Otherwise how to do that using Win32 APIs ?

Thanks

Edson
0
Comment
Question by:edsont
  • 3
  • 3
  • 2
8 Comments
 
LVL 30

Expert Comment

by:Zoppo
ID: 2680164
Hi edsont,

using PCL commands wouldn't be a good way coz it makes your program hardware dependant...

Better way: simply create a printer device context and a memory device context, load the bitmap, select it into the memory device context and from there blit it to the printer device context using StretchBlt() (or BitBlt() if you don't need scaling).

See help for PrintDlg, CreateCompatibleDC, SelectObject and StretchBlt...

you're welcome to ask if you have further question...

hope that helps,

ZOPPO
0
 

Author Comment

by:edsont
ID: 2680208
Zoppo,


Alternatively would you happen to know if PCL commands work in that context ?


Thanks

Edson
0
 
LVL 30

Expert Comment

by:Zoppo
ID: 2680253
If you need to use PCL commands (which is not recommended), you'll have to send your data directly (as raw data) to the printer without using the windows printer drivers. See MSDN article ID: Q138594 for how to do this.

ZOPPO
0
 

Author Comment

by:edsont
ID: 2680315
Zoppo,

Two more questions:

1. Would you know which PCL commands could be used ?
2. Does it exist any MSDN sample using printer device context way but without MFC classes ?

Thanks

Edson
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 30

Accepted Solution

by:
Zoppo earned 100 total points
ID: 2680365
1. Sorry, I don't have any knowledge about PCL.
2. I.e. MSDN article ID: Q139652 'Print a document'

again: It's strongly recommended to not use any hardware dependant printing. There's no advantage in using PCL. This would restrict your program to run only with printers which support PCL. Using windows GDI functions (based on device independant device context) is even simple and more flexible.

ZOPPO
0
 

Author Comment

by:edsont
ID: 2680501
My problem is that I already have a software that uses PCL commands to print. People asked for bitmap files printing but I wouldn't like to change it a lot.

Anyway I'll take atention to your suggestions.

Thanks

Edson
0
 

Expert Comment

by:jlislas
ID: 2753301
The writePrinter API function works with a printer handler. Tha printer handler can be obteined from an OpenPrinter API Function.

I think that if you create an array of bytes of your bitmaps, maybe you can print it using the writeprinter function.

I have the same problem, and the hard way is to send a Array of bytes for a BitMap through the writeprinter function

GetObject Picture1.Image, Len(PicInfo), PicInfo
'reallocate storage space
ReDim PicBits(1 To PicInfo.bmWidth * PicInfo.bmHeight * 3) As Byte
'Copy the bitmapbits to the array
GetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
'Invert the bits
For Cnt = 1 To UBound(PicBits)
PicBits(Cnt) = 255 - PicBits(Cnt)
Next Cnt
'Set the bits back to the picture
SetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
0
 

Expert Comment

by:jlislas
ID: 2753302
The writePrinter API function works with a printer handler. Tha printer handler can be obteined from an OpenPrinter API Function.

I think that if you create an array of bytes of your bitmaps, maybe you can print it using the writeprinter function.

I have the same problem, and the hard way is to send a Array of bytes for a BitMap through the writeprinter function

GetObject Picture1.Image, Len(PicInfo), PicInfo
'reallocate storage space
ReDim PicBits(1 To PicInfo.bmWidth * PicInfo.bmHeight * 3) As Byte
'Copy the bitmapbits to the array
GetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
'Invert the bits
For Cnt = 1 To UBound(PicBits)
PicBits(Cnt) = 255 - PicBits(Cnt)
Next Cnt
'Set the bits back to the picture
SetBitmapBits Picture1.Image, UBound(PicBits), PicBits(1)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now