Re: win32lib printing

new topic     » goto parent     » topic index » view thread      » older message » newer message

What printing device are you using? I am testing with CutePDF Writer as my printer and my bitmap printing comes out fine. Maybe the printer driver has something to do with it?

Also, you do not need to call setPenPos() to position the bitmap, since copyBlt() takes its position directly. That is only for text functions that do not accept positioning parameters (e.g. wPuts()).

Here is the code I am using to test.

include Win32Lib.ew 
 
constant 
    myWindow    = create( Window, "Test", 0, Default, Default, 400, 300, 0 ), 
    myButton    = create( PushButton, "Print", myWindow, 10, 10, 90, 30, 0 ), 
$ 
 
procedure myButton_OnClick( integer self, integer event, sequence params ) 
     
    sequence result = getPrinter() 
    if length( result ) = 0 then 
        -- user cancelled 
        return 
    end if 
     
    if startDoc( "Test" ) then 
         
        if startPage() then 
             
            atom bmp = loadBitmapFromFile( "space.bmp" ) 
             
            -- space.bmp is 300x225 (1.00" x 0.75"), so scale it up 8x to fill the page. 
            -- N.B. we are assuming 300 DPI here, which may not be correct (it's probably not). 
             
            stretchBlt( 
                Printer,  -- dest device 
                150,      -- dest x = 0.5" 
                150,      -- dest y = 0.5" 
                2400,     -- dest width = 8" 
                1800,     -- dest height = 6" 
                bmp,      -- src bitmap 
                0,        -- src x 
                0,        -- src y 
                300,      -- src width 
                225,      -- src height 
                SRCCOPY   -- operation 
            ) 
             
            endPage() 
             
        end if 
         
        endDoc() 
         
    end if 
     
    releasePrinter() 
     
end procedure 
setHandler( myButton, w32HClick, routine_id("myButton_OnClick") ) 
 
WinMain( myWindow, Normal ) 

-Greg

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu