1. Printing a Bitmap (Win32lib)
- Posted by david at aldred.demon.co.uk Jun 15, 2001
- 433 views
I asked for help on this a bit ago.... no answer... is there really no-one there who can help? I'm trying to print a bitmap from a windows program. Here's the code: procedure PrintButton_onClick () sequence result atom hBitmap result = getPrinter() if length( result ) then if not startDoc( "Trial Bitmap Print") then return end if if not startPage() then return end if hBitmap = loadBitmapFromFile("c:\\euphoria\\projects\\test.bmp" ) drawBitmap( Printer, hBitmap, 1, 1 ) if not endPage() then return end if if not endDoc() then return end if releasePrinter() end if end procedure This should load a bitmap, then print it: in fact what happens is that I get an error message telling me bitblt failed. If I tell it to continue anyway, I get a solid black square printed - it's the size of the bitmap in question but the bitmap isn't plain black! What's wrong? I've tried looking back through the mailing list archive but there doesn't seem to be a solution there.... -- ------------------ ------------------------- |\avid Aldred / David at aldred.demon.co.uk \ Nottingham, England |/ --------------------------------
2. Re: Printing a Bitmap (Win32lib)
- Posted by David Cuny <dcuny at LANSET.COM> Jun 16, 2001
- 398 views
David Aldred wrote: > I'm trying to print a bitmap from a windows > program. Here's the code: > ... > This should load a bitmap, then print it: in > fact what happens is that I get an error message > telling me bitblt failed. I get the same result on my printer. The only thing that comes to mind is that perhaps the printer doesn't support BitBlt. I don't have the constants handy to check this. If that's the problem, I don't really have a good solution available. -- David Cuny
3. Re: Printing a Bitmap (Win32lib)
- Posted by Wolf <wolfritz at KING.IGS.NET> Jun 16, 2001
- 397 views
I wrote an overly complicated bitmap printing demo quite some time ago, for win32lib ver. 55.1. I never could figure out the proper use of CreateCompatibleDC, CreateCompatibleBitMap, and SelectObject, so it's a bit of a mess. Perhaps someone like Tone Skoda, or Euman could simplify it, perhaps? All the bit-twiddling routines I stole from win32lib might not even be necessary. ... anyways, here it is: www.king.igs.net/~wolfritz/bits8-551.zip Wolf -- Arachne V1.66, NON-COMMERCIAL copy, http://arachne.cz/
4. Re: Printing a Bitmap (Win32lib)
- Posted by david at aldred.demon.co.uk Jun 16, 2001
- 401 views
In message <0.1700008810.1480117852-738719082-992678254 at topica.com>, David Cuny <dcuny at LANSET.COM> writes >David Aldred wrote: > >> I'm trying to print a bitmap from a windows >> program. Here's the code: >> ... >> This should load a bitmap, then print it: in >> fact what happens is that I get an error message >> telling me bitblt failed. > >I get the same result on my printer. The only thing that comes to mind is >that perhaps the printer doesn't support BitBlt. I don't have the constants >handy to check this. If that's the problem, I don't really have a good >solution available. I hadn't even thought that a printer might not support bitblt... However, having thought round it, here's a way of doing it which works. It's not pretty (all it does is grind through the bitmap and set each pixel), but it does the basic job! I really need to take it out of the button event and make it a separate routine, callable from anywhere, and incorporating offsets (this prints the bitmap in the top left corner) but that can follow on... procedure PushButton2_onClick () sequence plt, result atom colr x = read_bitmap("c:\\euphoria\\test.bmp") result = getPrinter() if length( result ) then if not startDoc( "My Job") then return end if if not startPage() then return end if for i=1 to length(x[2]) do for j=1 to length(x[2][i]) do plt = x[1][x[2][i][j]+1] colr = rgb(plt[1],plt[2],plt[3]) setPixel(Printer,j,i,colr) end for end for if not endPage() then return end if if not endDoc() then return end if releasePrinter() end if end procedure While we're on the subject, is there any way of getting a program to print to the default printer, without having to go through the printer selection dialogue each time? -- ------------------ ------------------------- |\avid Aldred / David at aldred.demon.co.uk \ Nottingham, England |/ --------------------------------
5. Re: Printing a Bitmap (Win32lib)
- Posted by Euman <euman at bellsouth.net> Jun 16, 2001
- 398 views
You must check to see if the printer is Raster Capable by useing: GetDeviceCaps(hdc, RASTERCAPS) value returned should be: RC_BITBLT or RC_STRETCHBLT etc...etc. if the printer is capable Wolfs print_pic( ) should be the perfect solution. if the printer is capable.. Not trying to step on your toes Wolf just thought I'd mention this cause I ran into a few printers that would not print a Bitmap and this is how I check to see if I can first... Euman euman at bellsouth.net ----- Original Message ----- From: "Wolf" <wolfritz at KING.IGS.NET> To: "EUforum" <EUforum at topica.com> Sent: Wednesday, June 06, 2001 15:36 Subject: Re: Printing a Bitmap (Win32lib) > > > I wrote an overly complicated bitmap printing demo quite some time ago, > for win32lib ver. 55.1. I never could figure out the proper use of > CreateCompatibleDC, CreateCompatibleBitMap, and SelectObject, so it's a > bit of a mess. Perhaps someone like Tone Skoda, or Euman could simplify > it, perhaps? All the bit-twiddling routines I stole from win32lib might > not even be necessary. > ... anyways, here it is: > www.king.igs.net/~wolfritz/bits8-551.zip > > Wolf > > -- Arachne V1.66, NON-COMMERCIAL copy, http://arachne.cz/ > > > >
6. Re: Printing a Bitmap (Win32lib)
- Posted by David Cuny <dcuny at LANSET.COM> Jun 16, 2001
- 408 views
Bernie Ryan wrote: > David C. what about device context? Don't you have > to set the printer DC to do this ? Off the top of my head, I thought the getPrinter stuff was supposed to do that. I'm only guessing that the problem is that the printer doesn't support BitBlt, but because none of the other operations failed, it's a likely candidate. As Euman pointed out, you can test this by calling GetDeviceCaps. I'd have tested it, but I don't have the constants RC_BITBLT handy. If it turns out that this is why the BitBlt fails (and at this point, it's just a conjecture), it would make sense to add the GetDeviceCaps test to BitBlt in the case of Printer, and fall through to David's code if it's not supported. -- David Cuny
7. Re: Printing a Bitmap (Win32lib)
- Posted by Euman <euman at bellsouth.net> Jun 16, 2001
- 395 views
DC here's the Constants RASTERCAPS = 38, RC_BANDING = 2, RC_BITBLT = 1, RC_BITMAP64 = 8, RC_DI_BITMAP = 128, RC_DIBTODEV = 512, RC_FLOODFILL = 4096, RC_GDI20_OUTPUT = 16, RC_PALETTE = 256, RC_SCALING = 4, RC_STRETCHBLT = 2048, RC_STRETCHDIB = 8192, RC_DEVBITS = #8000, RC_OP_DX_OUTPUT = #4000, Euman euman at bellsouth.net ----- Original Message ----- From: "David Cuny" <dcuny at LANSET.COM> To: "EUforum" <EUforum at topica.com> Sent: Saturday, June 16, 2001 16:50 Subject: Re: Printing a Bitmap (Win32lib) > > > Bernie Ryan wrote: > > > David C. what about device context? Don't you have > > to set the printer DC to do this ? > > Off the top of my head, I thought the getPrinter stuff was supposed to do > that. I'm only guessing that the problem is that the printer doesn't support > BitBlt, but because none of the other operations failed, it's a likely > candidate. > > As Euman pointed out, you can test this by calling GetDeviceCaps. I'd have > tested it, but I don't have the constants RC_BITBLT handy. > > If it turns out that this is why the BitBlt fails (and at this point, it's > just a conjecture), it would make sense to add the GetDeviceCaps test to > BitBlt in the case of Printer, and fall through to David's code if it's not > supported. > > -- David Cuny > > > >
8. Re: Printing a Bitmap (Win32lib)
- Posted by Jason <mirwalds at swbell.net> Jun 16, 2001
- 391 views
RC_BITBLT = 1 -- Can do standard BLT. -- > > Bernie Ryan wrote: > > > David C. what about device context? Don't you have > > to set the printer DC to do this ? > > Off the top of my head, I thought the getPrinter stuff was supposed to do > that. I'm only guessing that the problem is that the printer doesn't support > BitBlt, but because none of the other operations failed, it's a likely > candidate. > > As Euman pointed out, you can test this by calling GetDeviceCaps. I'd have > tested it, but I don't have the constants RC_BITBLT handy. > > If it turns out that this is why the BitBlt fails (and at this point, it's > just a conjecture), it would make sense to add the GetDeviceCaps test to > BitBlt in the case of Printer, and fall through to David's code if it's not > supported. > > -- David Cuny >
9. Re: Printing a Bitmap (Win32lib)
- Posted by David Cuny <dcuny at LANSET.COM> Jun 16, 2001
- 397 views
Euman wrote: > DC here's the Constants Thanks! If/when things settle down here I'll give it a shot. -- David Cuny
10. Re: Printing a Bitmap (Win32lib)
- Posted by David Cuny <dcuny at LANSET.COM> Jun 16, 2001
- 407 views
I wrote: result = getPrinter() if length( result ) then result = w32Func(xGetDeviceCaps, { getDC(Printer), RASTERCAPS } ) end if and got back a result of 11931 (#2E9B). The means the printer *should* support BitBlt, but it fails. -- David Cuny