Announcement

Collapse
No announcement yet.

XPRINT Problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • XPRINT Problem

    Any ideas why PB will not print a bitmap correctly with the following code?? Only the top part of the bitmap is printing out!
    Jim

    Code:
         xprint attach choose,title$
    
         orient&=2  ''landscape
         xprint set orientation orient&
    
         xprint get client to prwidth&,prheight&
    
         ff&=freefile
         open bmpfilename$ for binary as #ff& base=0
         seek #ff&,18
         get$ #ff&,8,b$
         close #ff&
    
         bmwidth&=cvl(left$(b$,4))
         bmheight&=cvl(right$(b$,4))
    
         ''msgbox str$(bmwidth&)+str$(bmheight&)+str$(prwidth&)+str$(prheight&)
         ''(sizes look correct)
    
         graphic bitmap load bmpfilename$,bmwidth&,bmheight& to hbmp&
    
         x&=prwidth&
         y&=bmheight&*(prwidth&/bmwidth&)
    
         xprint stretch hbmp&,0, _
                        (0,0)-(bmwidth&,bmheight&) to (0,0)-(x&,y&), _
                        %mix_copysrc
    
         xprint close
         graphic bitmap end
    Last edited by Jim Seekamp; 5 Sep 2008, 12:10 PM.
    Jim Seekamp

  • #2
    Although I still haven't figured out the problem, I've found that it prints fine when the window I did a screen capture from and created a bitmap with was on my main monitor.
    But when I dragged over to my second monitor (a larger one with better resolution) and had the program do the screen capture and created a bitmap with it, that bitmap (although the file is correct) did not print out correctly. Only the top part of the file printed out!

    I'll point out that both bitmap files were correct when I checked them before letting the print function do its thing, and the sizes pulled in from the xprint get client were both correct also.
    This looks like a bug in PB!
    Jim Seekamp

    Comment


    • #3
      See my post earlier in this forum. Xprint stretch does not handle the Y axis param properly. Xprint stretch will operate correctly on the entire bitmap.
      PB support is aware of this problem.

      John Tate

      Comment


      • #4
        Thanks John,
        But in the meantime, what is the workaround???
        graphic stretch does not stretch the bitmap at all, so I can't do an xprint copy after (attempting to) stretch the graphic itself!
        Jim
        Jim Seekamp

        Comment


        • #5
          Jim, I had to load only the portion of the bitmap that I wanted into the new bitmap. Then I xprint stretch that entire portion, which worked OK.
          Here is the code I came up with.

          Look at the "sub printposterfourpage"
          .
          I used this code to print out some pictures to the correct size to trace onto artist's canvas for painting.

          John Tate

          Code:
          #PBFORMS CREATED V1.51
          '------------------------------------------------------------------------------
          ' The first line in this file is a PB/Forms metastatement.
          ' It should ALWAYS be the first line of the file. Other
          ' PB/Forms metastatements are placed at the beginning and
          ' end of "Named Blocks" of code that should be edited
          ' with PBForms only. Do not manually edit or delete these
          ' metastatements or PB/Forms will not be able to reread
          ' the file correctly.  See the PB/Forms documentation for
          ' more information.
          ' Named blocks begin like this:    #PBFORMS BEGIN ...
          ' Named blocks end like this:      #PBFORMS END ...
          ' Other PB/Forms metastatements such as:
          '     #PBFORMS DECLARATIONS
          ' are used by PB/Forms to insert additional code.
          ' Feel free to make changes anywhere else in the file.
          '------------------------------------------------------------------------------
          
          #COMPILE EXE
          #DIM ALL
          
          '------------------------------------------------------------------------------
          '   ** Includes **
          '------------------------------------------------------------------------------
          #PBFORMS BEGIN INCLUDES
          %USEMACROS = 1
          #IF NOT %DEF(%WINAPI)
              #INCLUDE "WIN32API.INC"
          #ENDIF
          #IF NOT %DEF(%COMMCTRL_INC)
              #INCLUDE "COMMCTRL.INC"
          #ENDIF
          #INCLUDE "PBForms.INC"
          #PBFORMS END INCLUDES
          '------------------------------------------------------------------------------
          #INCLUDE "DDT.INC"
          #INCLUDE "dllprint.INC"
          
          '------------------------------------------------------------------------------
          '   ** Constants **
          '------------------------------------------------------------------------------
          #PBFORMS BEGIN CONSTANTS
          %IDD_DIALOG1    =  101
          %IDC_GRAPHIC1   = 1001
          %IDC_BUTTON1    = 1002
          %IDCANCEL       =    2
          %IDC_LABEL1     = 1003
          %IDC_LABEL2     = 1004
          %IDC_LABEL3     = 1005
          %IDC_TEXTBOX1   = 1006
          %IDC_TEXTBOX2   = 1007
          %IDC_LABEL4     = 1008
          %IDC_TEXTBOX3   = 1009
          %IDC_TEXTBOX4   = 1010
          %IDC_LABEL5     = 1011
          %IDC_LABEL6     = 1012
          %IDC_OPTION1    = 1013
          %IDC_OPTION2    = 1014
          %IDC_LABEL7     = 1015  '*
          %IDC_LABEL8     = 1016
          %IDC_TEXTBOX5   = 1017
          %IDC_GETPICTURE = 1018
          #PBFORMS END CONSTANTS
          '------------------------------------------------------------------------------
          
          '------------------------------------------------------------------------------
          '   ** Declarations **
          '------------------------------------------------------------------------------
          DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
          DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
          #PBFORMS DECLARATIONS
          '------------------------------------------------------------------------------
          DECLARE SUB PRINTPOSTERfourPage(hDlg AS DWORD)
          DECLARE SUB PRINTPOSTERonePage(hDlg AS DWORD)
          '------------------------------------------------------------------------------
          '   ** Main Application Entry Point **
          '------------------------------------------------------------------------------
          FUNCTION PBMAIN()
              PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR _
                  %ICC_INTERNET_CLASSES)
          
              ShowDIALOG1 %HWND_DESKTOP
          END FUNCTION
          '------------------------------------------------------------------------------
          
          '------------------------------------------------------------------------------
          '   ** CallBacks **
          '------------------------------------------------------------------------------
          CALLBACK FUNCTION ShowDIALOG1Proc()
          STATIC bmpfilename,tempvar AS STRING
          STATIC oWidth,oHeight AS SINGLE
          STATIC x,y AS LONG
          LOCAL FILENAME AS STRING
          STATIC hBmp AS DWORD
          FILENAME= ""
              SELECT CASE AS LONG CBMSG
                  CASE %WM_INITDIALOG
                      ' Initialization handler
          '
                   CONTROL SET OPTION CB.HNDL,%IDC_OPTION1,%IDC_OPTION1,%IDC_OPTION2
                   CONTROL SET TEXT CB.HNDL, %idc_textbox3, "8.5"
                   CONTROL SET TEXT CB.HNDL, %idc_textbox4, "11"
                   CONTROL SET FOCUS CB.HNDL, %IDC_GETPICTURE
                  CASE %WM_NCACTIVATE
                      STATIC hWndSaveFocus AS DWORD
                      IF ISFALSE CBWPARAM THEN
                          ' Save control focus
                          hWndSaveFocus = GetFocus()
                      ELSEIF hWndSaveFocus THEN
                          ' Restore control focus
                          SetFocus(hWndSaveFocus)
                          hWndSaveFocus = 0
                      END IF
          
                  CASE %WM_COMMAND
                      ' Process control notifications
                      SELECT CASE AS LONG CB.CTL
                          CASE %IDC_GRAPHIC1
          
                          CASE %IDC_GETPICTURE
                            DISPLAY OPENFILE CB.HNDL, , , "pictures", "c:\PBWINTST", CHR$("pics"+ CHR$(0)+"*.bmp"+ CHR$(0)), _
            "", "", %OFN_FILEMUSTEXIST TO FILENAME
          '    ' MSGBOX " bitmap size = " +STR$(x)+ "x" + STR$(y)
          '
                 CONTROL SET TEXT CB.HNDL ,%IDC_TEXTBOX5, FILENAME
                    GRAPHIC ATTACH CB.HNDL, %IDC_GRAPHIC1
                    GRAPHIC CLEAR
                    OPEN filename FOR BINARY AS #1  'my own photo to load
                      GET #1,19,x
                      GET #1,23,y
                      CLOSE 1
                   IF x > y THEN GRAPHIC RENDER FILENAME,(0,0)-(420,270)
                   IF x < y THEN GRAPHIC RENDER FILENAME,(0,0)-(270,270)
                   'IF X < Y THEN GRAPHIC bitmap load filename,x,y to hBmp
                   'graphic stretch hbmp, %idc_graphic1 ,(0,0)-(x,y) to (0,0)-(270,420)
                          CASE %idc_textbox5
          '
          
          
                          CASE %IDC_BUTTON1
                              IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
                              CONTROL GET TEXT CB.HNDL, %idc_textbox1 TO tempvar:oWidth = VAL(tempvar)
                              CONTROL GET TEXT CB.HNDL, %idc_textbox2 TO tempvar:oHeight= VAL(tempvar)
                            '  MSGBOX "outputwide"+ STR$(oWidth) + $CRLF + "outputhigh" + STR$(oHeight)
                              IF oWidth < 11 AND oHeight < 11 THEN printposteronepage(CB.HNDL) ELSE printposterfourPage(CB.HNDL)
                              END IF
          
                          CASE %IDCANCEL
                              IF CB.CTLMSG = %BN_CLICKED OR CB.CTLMSG = 1 THEN
          
                                  DIALOG END CB.HNDL, 0
                              END IF
          
                      END SELECT
              END SELECT
          END FUNCTION
          '------------------------------------------------------------------------------
          
          '------------------------------------------------------------------------------
          '   ** Dialogs **
          '------------------------------------------------------------------------------
          FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
              LOCAL lRslt AS LONG
          
          #PBFORMS BEGIN DIALOG %IDD_DIALOG1->->
              LOCAL hDlg  AS DWORD
          
              DIALOG NEW hParent, "POSTER PRINT PROGRAM   software by John Tate", 9, _
                  66, 615, 340, TO hDlg
              CONTROL ADD BUTTON,  hDlg, %IDC_GETPICTURE, "SELECT A PICTURE", 495, 40, _
                  80, 15
              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "", 505, 75, 50, 13
              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "", 505, 95, 50, 13
              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX3, "", 510, 140, 50, 13
              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX4, "", 510, 160, 50, 13
              CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "PRINT POSTER", 125, 305, 85, 15
              CONTROL ADD BUTTON,  hDlg, %IDCANCEL, "EXIT", 270, 305, 50, 15
              CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX5, "", 485, 20, 100, 13
              ' %WS_GROUP...
              CONTROL ADD OPTION,  hDlg, %IDC_OPTION1, "PORTAIT", 455, 190, 100, 10, _
                  %WS_TABSTOP OR %BS_LEFT OR %BS_VCENTER OR %WS_GROUP OR %WS_CHILD OR _
                  %WS_VISIBLE, %WS_EX_LEFT OR %WS_EX_LTRREADING
              CONTROL ADD OPTION,  hDlg, %IDC_OPTION2, "LANDSCAPE", 455, 205, 100, 10, _
                  %WS_TABSTOP OR %BS_LEFT OR %BS_VCENTER OR %WS_CHILD OR %WS_VISIBLE, _
                  %WS_EX_LEFT OR %WS_EX_LTRREADING
              ' %WS_GROUP...
              CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 5, 5, 425, 275, %WS_GROUP _
                  OR %WS_CHILD OR %WS_VISIBLE
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "OUT PUT SIZE", 495, 60, 70, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL2, "WIDTH", 450, 75, 50, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL3, "HEIGHT", 450, 95, 50, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL4, "PAPER SIZE", 505, 120, 70, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL5, "WIDTH", 455, 140, 50, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL6, "HEIGHT", 455, 160, 50, 10
              CONTROL ADD LABEL,   hDlg, %IDC_LABEL8, "picture file name", 500, 10, 65, _
                  10
          #PBFORMS END DIALOG
          
              DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
          
          #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
          #PBFORMS END CLEANUP
          
              FUNCTION = lRslt
          END FUNCTION
          '------------------------------------------------------------------------------
          SUB PRINTPOSTERfourPage(hDlg AS DWORD)
             ' MSGBOX "IN FOUR PAGE"
          STATIC hbmp ,hnewbmp AS DWORD
          LOCAL x,y,pgx,pgy,portraitlandscape,tempheight,tempwidth AS LONG
          LOCAL TEMPVAR AS STRING
          LOCAL wOutput,hOutput,paperwidth,paperheight,pwidth,pheight AS SINGLE
          STATIC bmpfilename AS STRING
          CONTROL GET TEXT hDlg,%idc_textbox1 TO tempvar:wOutput = VAL(tempvar)
          CONTROL GET TEXT hDlg,%idc_textbox2 TO tempvar:hOutput = VAL(tempvar)
          CONTROL GET CHECK hdlg,%idc_option1 TO portraitlandscape
          CONTROL GET TEXT hdlg,%idc_textbox3 TO tempvar:pwidth = VAL(tempvar)
          CONTROL GET TEXT hdlg,%idc_textbox4 TO tempvar:pheight = VAL(tempvar)
          CONTROL GET TEXT hDlg,%idc_textbox5 TO bmpfilename
           OPEN bmpfilename FOR BINARY AS #1
                      GET #1,19,x 'width of bmp
                      GET #1,23,y 'height of bmp
                      CLOSE 1
          '     MSGBOX " bitmap size = " +STR$(x)+ "x" + STR$(y)
          
          IF ERR THEN MSGBOX "error"
          GRAPHIC BITMAP LOAD bmpfilename$,x,y TO hbmp
             ' MSGBOX STR$(hbmp)
              XPRINT ATTACH DEFAULT
              IF portraitlandscape = 1 THEN XPRINT SET ORIENTATION 1
              IF portraitlandscape = 0 THEN XPRINT SET ORIENTATION 2
              XPRINT GET SIZE TO pgx,pgy ':msgbox str$(pgy)
              'portrait width,height
              IF portraitlandscape = 1 THEN
                  paperwidth = pwidth *.96
                  paperheight = pheight *.96
                  END IF
              'landscape width,height
               IF portraitlandscape = 0 THEN
                  paperwidth = pwidth *.96
                  paperheight = pheight *.96
                  END IF
          '    MSGBOX "paper/wdth/pixels "+ STR$(pgx)+$CRLF+ "paper/ht/pixels "+STR$(pgy)+$CRLF + "TEMPwidth "+ STR$(TEMPWIDTH)+$CRLF+ "TEMPheight "+STR$(tempheight) + _
           '   $CRLF +  "PAPERWIDTH " + STR$(paperwidth) +$CRLF +"paper height"+ STR$(paperheight) +$CRLF+ "pixels/inch/wide" +STR$( ((pgx/paperwidth)*(woutput/2))) + _
            '  $CRLF +   "pixels/inch/height" +STR$( ((pgy/paperheight)*(hOutput/2))) +$CRLF +"picture wdth "+STR$(x) +$CRLF + _
             ' "picture ht " + STR$(y)
          'EXIT SUB
          GRAPHIC BITMAP NEW x,y TO hnewbmp
          GRAPHIC ATTACH hnewbmp,0
                GRAPHIC STRETCH hbmp,0,(0,0)-(x/2,y/2) TO (0,0)-(x,y)  'upper left corner to orginal size of photo    '
              XPRINT STRETCH hnewbmp,0,(0,0)-(x,y) TO (100,100)-(INT((pgx/paperwidth)*(woutput/2)),INT((pgy/paperheight)*(hOutput/2))) 'now stretch to size wanted on
              XPRINT FORMFEED
              GRAPHIC STRETCH hbmp,0,(x/2,0)-(x,y/2) TO (0,0)-(x,y)  'upper right corner
              XPRINT STRETCH hnewbmp,0,(0,0)-(x,y) TO (100,100)-(INT((pgx/paperwidth)*(woutput/2)),INT((pgy/paperheight)*(houtput/2))) 'now stretch to size wanted on
              XPRINT FORMFEED
               GRAPHIC STRETCH hbmp,0,(0,y/2)-(x/2,y) TO (0,0)-(x,y)  'lower left corner
              XPRINT STRETCH hnewbmp,0,(0,0)-(x,y) TO (100,100)-(INT((pgx/paperwidth)*(woutput/2)),INT((pgy/paperheight)*(houtput/2))) 'now stretch to size wanted on
              XPRINT FORMFEED
                GRAPHIC STRETCH hbmp,0,(x/2,y/2)-(x,y) TO (0,0)-(x,y) 'lower right corner
              XPRINT STRETCH hnewbmp,0,(0,0)-(x,y) TO (100,100)-(INT((pgx/paperwidth)*(woutput/2)),INT((pgy/paperheight)*(houtput/2))) 'now stretch to size wanted on
          XPRINT CLOSE
          GRAPHIC BITMAP END
          MSGBOX "ALL PAGES PRINTED"
          END SUB
          '--------------------------------------------------------
          SUB PRINTPOSTERonepage(hDlg AS DWORD)
          STATIC hbmp ,hnewbmp AS DWORD
          LOCAL x,y,pgx,pgy,portraitlandscape,tempheight,tempwidth AS LONG
          LOCAL TEMPVAR AS STRING
          LOCAL wOutput,hOutput,paperwidth,paperheight,pwidth,pheight AS SINGLE
          STATIC bmpfilename AS STRING
          CONTROL GET TEXT hDlg,%idc_textbox1 TO tempvar:wOutput = VAL(tempvar)
          CONTROL GET TEXT hDlg,%idc_textbox2 TO tempvar:hOutput = VAL(tempvar)
          CONTROL GET CHECK hdlg,%idc_option1 TO portraitlandscape
          CONTROL GET TEXT hdlg,%idc_textbox3 TO tempvar:pwidth = VAL(tempvar)
          CONTROL GET TEXT hdlg,%idc_textbox4 TO tempvar:pheight = VAL(tempvar)
          CONTROL GET TEXT hDlg,%idc_textbox5 TO bmpfilename
           OPEN bmpfilename FOR BINARY AS #1
                      GET #1,19,x 'width of bmp
                      GET #1,23,y 'height of bmp
                      CLOSE 1
              ' MSGBOX " bitmap size = " +STR$(x)+ "x" + STR$(y)
          
          IF ERR THEN MSGBOX "error"
          GRAPHIC BITMAP LOAD bmpfilename$,x,y TO hbmp
             ' MSGBOX STR$(hbmp)
              XPRINT ATTACH CHOOSE
              IF portraitlandscape = 1 THEN XPRINT SET ORIENTATION 1
              IF portraitlandscape = 0 THEN XPRINT SET ORIENTATION 2
              'XPRINT GET SIZE TO pgx,pgy ':msgbox str$(pgy)
              'paperwidth = pwidth *.96
              'paperheight = pheight *.96
              'portrait width,height
                  IF portraitlandscape = 1 THEN
                   XPRINT GET SIZE TO pgx,pgy
                  paperwidth = pwidth *.96
                  paperheight = pheight
                  END IF
              'landscape width,height
               IF portraitlandscape = 0 THEN
          
                    XPRINT GET SIZE TO pgx,pgy :
                  paperwidth = pwidth  * 1.28
                  paperheight = pheight*.77
                  END IF
          'EXIT SUB
          GRAPHIC BITMAP NEW x,y TO hnewbmp
          GRAPHIC ATTACH hnewbmp,0
               GRAPHIC STRETCH hbmp,0,(0,0)-(x,y) TO (0,0)-(x,y) 'stretch entire picture into new bitmap
              XPRINT STRETCH hnewbmp,0,(0,0)-(x,y) TO (0,0)-(INT((pgx/paperwidth)*(woutput)),INT((pgy/paperheight)*(hOutput))) 'now stretch to size wanted on
          GRAPHIC ATTACH hBmp,0:GRAPHIC BITMAP END
          GRAPHIC ATTACH hnewbmp,0:GRAPHIC BITMAP END
          
          XPRINT CLOSE
          MSGBOX "SINGLE PAGE PRINTED"
          END SUB
          '--------------------------------------------------------

          Comment


          • #6
            John, it appears we have different problems.
            I already am printing out the entire bitmap; I am not only printing parts of it!
            I think my problem has to do with my 2-monitor system, having 2 different sized monitors. It works fine printing the bitmap of the screen shot of the first monitor, but doesn't work on the bitmap created from the screen shot from the second monitor! (which has a different resolution).

            All I was trying to do was print out the bitmap to a printer, and for one full bitmap it worked and for the other full bitmap it did not!
            Jim Seekamp

            Comment


            • #7
              Try changing the bitmap width and height from longs to singles. I had to use single variables to get my program to work properly.

              John Tate

              Comment


              • #8
                I went back to the sample program I sent to PB support and could not get it to misfire. I then realized I was compiling it in PB9. I ran the same program in PB8 and it refused to print the lower right and lower left of my bitmap.
                I can only assume there is something different in PB9 and xprint stretch is working as advertised.

                Jim, in PB9, changing the variables from longs to singles and back again did not make any difference. It seemed to in PB8.

                Sorry that I misread your post - that you are xprint stretching the entire bitmap. However, it seems to be similiar to what I experienced in PB8. If you are compiling in PB8, it would appear that the the y value is not the total height of the bitmap, and would not print lower portions of the bitmap, but only top portions.

                John Tate

                Comment


                • #9
                  Thanks for the info, John...
                  I ordered PB9 over a week ago and have not yet received it; but when I do... LOL
                  In the meantime I am using the Windows API directly and abandoning the XPRINT stuff. I can't use functions that are not reliable, as I'll hear about it from my company's customers.
                  Thanks
                  Jim
                  Jim Seekamp

                  Comment


                  • #10
                    Are you sure you are reading the size of the bitmap right? I use the following.
                    Code:
                        local nwidth as long
                        local nheight as long
                        OPEN  textp FOR BINARY AS i
                        GET #i, 19, nWidth
                        GET #i, 23, nHeight
                        CLOSE #i
                    This is from the help file for pbwin 8.x
                    Keith Shelton

                    Comment


                    • #11
                      Yes Keith, I'm getting the right size.
                      (I'm so used to base 0 binary files that I always use them instead of the default. if you read from position 0 in an open base 0 binary read, it's the same as position 1 in default.)
                      Jim Seekamp

                      Comment

                      Working...
                      X