Stretchblt to printer woes ... (aka please help!) 
Author Message
 Stretchblt to printer woes ... (aka please help!)

I am using this routine to print a .bmp file from a VB6 project, using
API's. For larger files, the bitmap is printed. For smaller files,
StretchBlt returns non-zero, but nothing comes out on the printer page.
GetDeviceCaps informs me that Stretchblt is supported by the printer.

Please help a relative newbie at his wits end who has searched Dejanews to
no avail. What areas could I look at in fixing this (IMO) strange problem.

Thanks,
Iestyn.

ps. I have included the Stretchblt code below ...
---------------

Private Sub sDisplayTest(DispObj As Object)
Dim lMemDC As Long
Dim lOldObject As Long
Dim lBMPHandle As Long
Dim sLocation As String
Dim lResult As Long
Dim BM As BITMAP
Dim DestX As Long, DestY As Long
Dim DestWidth As Long, DestHeight As Long
Dim SrcWidth As Long, SrcHeight As Long

    sLocation = "C:\Test\seal.bmp"
    lMemDC = CreateCompatibleDC&(DispObj.hdc)
    lBMPHandle = LoadImage(0, sLocation, IMAGE_BITMAP, 0, 0, LR_DEFAULTCOLOR
+ LR_LOADFROMFILE)
    lResult = GetObjectAPI(lBMPHandle, Len(BM), BM)
    lOldObject = SelectObject(lMemDC, lBMPHandle)

    DestWidth = DispObj.ScaleX(DispObj.ScaleWidth, DispObj.ScaleMode,
vbPixels) / 2
    DestHeight = DispObj.ScaleY(DispObj.ScaleHeight, DispObj.ScaleMode,
vbPixels) / 2
    SrcWidth = BM.bmWidth
    SrcHeight = BM.bmHeight
    DestX = DispObj.ScaleX(DispObj.ScaleLeft - DispObj.ScaleLeft,
DispObj.ScaleMode, vbPixels)
    DestY = DispObj.ScaleY(DispObj.ScaleTop - DispObj.ScaleTop,
DispObj.ScaleMode, vbPixels)

    lResult = StretchBlt(DispObj.hdc, DestX, DestY, _
            DestWidth, DestHeight, _
            lMemDC, 0, 0, SrcWidth, SrcHeight, SRCCOPY)

    lResult = SelectObject(lMemDC, lOldObject)
    lResult = DeleteObject(lBMPHandle)
    lResult = DeleteDC(lMemDC)

End Sub



Fri, 04 Jul 2003 13:42:36 GMT  
 Stretchblt to printer woes ... (aka please help!)
You can't stretchblt from one hdc type to another (i.e, screen to printer).
Well, sometimes it works, but not others.  To get consistent results you
have to create a DIB and select it into the printer DC.
(think: CreateDIB, SelectObject, etc...)

Eric


Quote:
> I am using this routine to print a .bmp file from a VB6 project, using
> API's. For larger files, the bitmap is printed. For smaller files,
> StretchBlt returns non-zero, but nothing comes out on the printer page.
> GetDeviceCaps informs me that Stretchblt is supported by the printer.

> Please help a relative newbie at his wits end who has searched Dejanews to
> no avail. What areas could I look at in fixing this (IMO) strange problem.

> Thanks,
> Iestyn.

> ps. I have included the Stretchblt code below ...
> ---------------

> Private Sub sDisplayTest(DispObj As Object)
> Dim lMemDC As Long
> Dim lOldObject As Long
> Dim lBMPHandle As Long
> Dim sLocation As String
> Dim lResult As Long
> Dim BM As BITMAP
> Dim DestX As Long, DestY As Long
> Dim DestWidth As Long, DestHeight As Long
> Dim SrcWidth As Long, SrcHeight As Long

>     sLocation = "C:\Test\seal.bmp"
>     lMemDC = CreateCompatibleDC&(DispObj.hdc)
>     lBMPHandle = LoadImage(0, sLocation, IMAGE_BITMAP, 0, 0,
LR_DEFAULTCOLOR
> + LR_LOADFROMFILE)
>     lResult = GetObjectAPI(lBMPHandle, Len(BM), BM)
>     lOldObject = SelectObject(lMemDC, lBMPHandle)

>     DestWidth = DispObj.ScaleX(DispObj.ScaleWidth, DispObj.ScaleMode,
> vbPixels) / 2
>     DestHeight = DispObj.ScaleY(DispObj.ScaleHeight, DispObj.ScaleMode,
> vbPixels) / 2
>     SrcWidth = BM.bmWidth
>     SrcHeight = BM.bmHeight
>     DestX = DispObj.ScaleX(DispObj.ScaleLeft - DispObj.ScaleLeft,
> DispObj.ScaleMode, vbPixels)
>     DestY = DispObj.ScaleY(DispObj.ScaleTop - DispObj.ScaleTop,
> DispObj.ScaleMode, vbPixels)

>     lResult = StretchBlt(DispObj.hdc, DestX, DestY, _
>             DestWidth, DestHeight, _
>             lMemDC, 0, 0, SrcWidth, SrcHeight, SRCCOPY)

>     lResult = SelectObject(lMemDC, lOldObject)
>     lResult = DeleteObject(lBMPHandle)
>     lResult = DeleteDC(lMemDC)

> End Sub



Sat, 11 Oct 2003 05:36:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Using HP Printer Escape Sequences (aka Printer Passthrough Codes) in VB.Net

2. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

3. Please need help on stretchblt !

4. Help with StretchBlt() please

5. Please Need help on Stretchblt or Paintpicture.

6. IE Band Object, COM woes Please help.

7. Clipboard API woes...Please HElp

8. Setup woes: PLEASE help!!!!!!!!!!!!

9. Access and ODBC Woes ....Please help!

10. ADO woes w/ multiple tables (help please)

11. Can anyone HELP me PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE PLEASE

12. QBasic Printer Woes

 

 
Powered by phpBB® Forum Software