?
Solved

How to print a Windows Bitmap file ?

Posted on 2000-04-03
8
Medium Priority
?
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
8 Comments
 
LVL 31

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 31

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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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
 
LVL 31

Accepted Solution

by:
Zoppo earned 300 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

718 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