Announcement

Collapse
No announcement yet.

xprint stretch vs graphic stretch

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

  • xprint stretch vs graphic stretch

    I want to divide a bitmap into 4 pieces and dump the 4 pieces to paper- like poster printing.
    I can get the bitmap to show each quadrant in my graphic window, but using the same code for xprint stretch gives me uneven results.
    I copied the 4 lines of code for the graphic stretch routine and changed them to xprint stretch.
    I cannot get the lower left quadrant and the lower right quadrant to print to paper- yet the statements work ok for the graphic window.
    What am I missing?
    Here is the code I have been working with.

    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
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** 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
    #PBFORMS END CONSTANTS
    '------------------------------------------------------------------------------
    
    '------------------------------------------------------------------------------
    '   ** Declarations **
    '------------------------------------------------------------------------------
    DECLARE CALLBACK FUNCTION ShowDIALOG1Proc()
    DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG
    #PBFORMS DECLARATIONS
    '------------------------------------------------------------------------------
    DECLARE SUB PRINTPOSTER(hDlg AS LONG)
    '------------------------------------------------------------------------------
    '   ** 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 hCousinsbmp AS DWORD
    hcousinsbmp = 100021???
    
    LOCAL x,y AS LONG
    
        SELECT CASE AS LONG CBMSG
            CASE %WM_INITDIALOG
                ' Initialization handler
                OPEN "cousins.bmp" FOR BINARY AS #1  'my own photo to load
                GET #1,19,x
                GET #1,23,y
                CLOSE 1
               
                
        ' MSGBOX " bitmap size = " +STR$(x)+ "x" + STR$(y)
    GRAPHIC BITMAP LOAD "cousins.bmp",x,y TO hcousinsbmp
    
              GRAPHIC ATTACH CBHNDL, %IDC_GRAPHIC1
              GRAPHIC STRETCH hcousinsbmp,0,(x/2,y/2)-(x,y) TO (0,0)-(420,270) 'lower right corner
              'GRAPHIC STRETCH hcousinsbmp,0,(0,y/2)-(x/2,y) TO (0,0)-(420,270)  'lower left corner
              'GRAPHIC STRETCH hcousinsbmp,0,(x/2,0)-(x,y/2) TO (0,0)-(420,270)  'upper right corner
              'GRAPHIC STRETCH hcousinsbmp,0,(0,0)-(x/2,y/2) TO (0,0)-(420,270)  'upper left corner
            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 CBCTL
                    CASE %IDC_GRAPHIC1
    
                    CASE %IDC_BUTTON1
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            'graphic bitmap end
                            printposter(CBHNDL)
                        END IF
    
                    CASE %IDCANCEL
                        IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                            DIALOG END CBHNDL, 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, "Dialog1", 9, 66, 615, 340, TO hDlg
        CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 5, 5, 425, 275
        CONTROL ADD BUTTON,  hDlg, %IDC_BUTTON1, "PRINT POSTER", 125, 305, 85, 15
        CONTROL ADD BUTTON,  hDlg, %IDCANCEL, "EXIT", 270, 305, 50, 15
        CONTROL ADD LABEL,   hDlg, %IDC_LABEL1, "OUT PUT SIZE", 470, 10, 125, 10
        CONTROL ADD LABEL,   hDlg, %IDC_LABEL2, "WIDTH", 450, 30, 50, 10
        CONTROL ADD LABEL,   hDlg, %IDC_LABEL3, "HEIGHT", 450, 45, 50, 10
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX1, "TextBox1", 505, 30, 50, 13
        CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX2, "TextBox2", 505, 45, 50, 13
    #PBFORMS END DIALOG
    
        DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt
    
    #PBFORMS BEGIN CLEANUP %IDD_DIALOG1
    #PBFORMS END CLEANUP
    
        FUNCTION = lRslt
    END FUNCTION
    '------------------------------------------------------------------------------
    SUB PRINTPOSTER(hDlg AS DWORD)
    STATIC hCousinsbmp AS DWORD
    hcousinsbmp = 100021???
    LOCAL x,y,pgx,pgy,x2,y2 AS LONG
    LOCAL TEMPVAR AS STRING
    LOCAL wOutput,hOutput AS LONG
    CONTROL GET TEXT hDlg,%idc_textbox1 TO tempvar:wOutput = VAL(tempvar)
    CONTROL GET TEXT hDlg,%idc_textbox2 TO tempvar:hOutput = VAL(tempvar)
     OPEN "cousins.bmp" 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)
    GRAPHIC BITMAP LOAD "cousins.bmp",x,y TO hcousinsbmp  'load entire bitmap
    IF ERR THEN MSGBOX "error"
       ' MSGBOX STR$(hdlg)
        XPRINT ATTACH DEFAULT
        XPRINT SET ORIENTATION 2
        XPRINT GET SIZE TO pgx,pgy
             '   xprint stretch hcousinsbmp,0,(x/2,y/2)-(x,y) to (0,0)-(pgx*.6,pgy*.6) 'lower right corner --prints upper right
              'xprint STRETCH hcousinsbmp,0,(0,y/2)-(x/2,y) TO (0,0)-(pgx*.6,pgy*.6)  'lower left corner  --prints upper left
              'xprint STRETCH hcousinsbmp,0,(x/2,0)-(x,y/2) TO (0,0)-(pgx*.6,pgy*.6)  'upper right corner --print ok
              XPRINT STRETCH hcousinsbmp,0,(0,0)-(x/2,y/2) TO (0,0)- (pgx*.6,pgy*.6)  'upper left corner
    XPRINT CLOSE
    GRAPHIC BITMAP END
    END SUB
    Thanks for any help you can give me.

    John Tate

  • #2
    I put the above information into PB support and they were able to replicate the problem. A fix will be forthcoming.

    John Tate

    Comment

    Working...
    X