Announcement

Collapse
No announcement yet.

Display BMP as small size and other

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

  • #21
    The code can be more "minimal" if you take advantage of the 'GRAPHIC STRETCH PAGE' form of the statement.
    Code:
    #Compiler PBWin 10
    #Compile Exe
    #Dim All
    %Unicode=1
    #Include "Win32API.inc"
    
    %IDC_Graphic = 600
    
    Function PBMain() As Long
     Local hDlg As Dword
    
      Dialog New Pixels, 0, "Image Resize",300,300,300,200, %WS_OverlappedWindow To hDlg
       Control Add Graphic, hDlg, %IDC_Graphic,"",10,10,10,10, %WS_Border
       Graphic Attach hDlg, %IDC_Graphic
      Dialog Show Modal hDlg Call DlgProc
    End Function
    
    CallBack Function DlgProc() As Long
     Static hBmp As Dword
      Select Case Cb.Msg
        Case %WM_InitDialog
         Local S_FileName As String
          ' Choose bitmap
          S_FileName = "image_11038.bmp"                  ' (eg Image copied from post#8)
          Graphic Bitmap Load S_FileName, 00, 00 TO hBMP  ' put image in memory bitmap - image size
    
        Case %WM_Size
          Control Set Size Cb.Hndl, %IDC_Graphic, Lo(Word, Cb.lParam)-20, Hi(Word, Cb.lParam)-20
          Graphic Attach Cb.Hndl, %IDC_Graphic
          Graphic Stretch Page hBmp, 0, 0, %HALFTONE      ' shortcut, copy complete bitmap to attached target
    
        Case %WM_GetMinMaxInfo
         Local MinMaxPtr As Minmaxinfo Ptr                ' Restrict minimum dialog height
          MinMaxPtr = CBLPARAM                            ' to avoid corruption
          @MinMaxPtr.ptMinTrackSize.y = 80                ' (of control's DC ?)
    
       End Select
    End Function '
    Rgds, Dave

    Comment


    • #22
      Dear all,

      thank you for assisting. I keep getting a viral hit from crowdstrike and am working with IT to get a pass on this.

      Click image for larger version

Name:	Crowdstrike.png
Views:	64
Size:	11.3 KB
ID:	796436
      It is weird: I am trying to toggle the BMP on a double click this is causing the intercept.

      However, I could compile the above version successfully. Here is Ceres.

      Click image for larger version

Name:	New Model.png
Views:	42
Size:	110.3 KB
ID:	796437

      This is very nice. I need to try to understand what I am doing and see how best to adopt it. I will show the result once I work it into the planetary constants dialog. In addition, I need to figure out how to switch BMPs. I figure its as simple as just loading. Not sure how to push the redraw or if it is even needed. Again, Crowdstrike is whacking this so I can't test it.

      Code:
      #COMPILER PBWIN 10
      #COMPILE EXE
      #DIM ALL
      %Unicode=1
      #INCLUDE "Win32API.inc"
      
      %IDC_Graphic = 600
      
      FUNCTION PBMAIN() AS LONG
      LOCAL hDlg AS DWORD
      
      DIALOG NEW PIXELS, 0, "Image Resize",300,300,300,200, %WS_OVERLAPPEDWINDOW TO hDlg
      CONTROL ADD GRAPHIC, hDlg, %IDC_Graphic,"",10,10,10,10, %WS_BORDER
      GRAPHIC ATTACH hDlg, %IDC_Graphic
      DIALOG SHOW MODAL hDlg CALL DlgProc
      END FUNCTION
      
      CALLBACK FUNCTION DlgProc() AS LONG
      DIM L_FLIP AS STATIC LONG
      DIM S_FileName1 AS STRING
      DIM S_FileName2 AS STRING
      STATIC hBmp AS DWORD
      SELECT CASE CB.MSG
      CASE %WM_INITDIALOG
      DIM S_FileName AS STATIC STRING
      ' Choose bitmap
      S_FileName1 = "C:\Odin_local_backup\Work LynxCAT\Software\LYX\LynxCAT\Schedule AST PLA\Texture Maps\Ceres.bmp" ' (eg Image copied from post#8)
      GRAPHIC BITMAP LOAD S_FileName1, 00, 00 TO hBMP ' put image in memory bitmap - image size
      
      CASE %WM_SIZE
      CONTROL SET SIZE CB.HNDL, %IDC_Graphic, LO(WORD, CB.LPARAM)-20, HI(WORD, CB.LPARAM)-20
      GRAPHIC ATTACH CB.HNDL, %IDC_Graphic
      GRAPHIC STRETCH PAGE hBmp, 0, 0, %HALFTONE ' shortcut, copy complete bitmap to attached target
      
      
      CASE %WM_LBUTTONDBLCLK
      
      L_FLIP = NOT L_FLIP
      IF L_FLIP THEN
      
      S_FileName1 = "C:\Odin_local_backup\Work LynxCAT\Software\LYX\LynxCAT\Schedule AST PLA\Texture Maps\Ceres.bmp" ' (eg Image copied from post#8)
      GRAPHIC BITMAP LOAD S_FileName1, 00, 00 TO hBMP 'put image in memory bitmap
      
      ELSE
      
      S_FileName2 = "C:\Odin_local_backup\Work LynxCAT\Software\LYX\LynxCAT\Schedule AST PLA\Texture Maps\Moon Luna.bmp" ' (eg Image copied from post#8)
      GRAPHIC BITMAP LOAD S_FileName2, 00, 00 TO hBMP 'put image in memory bitmap
      
      END IF
      
      CASE %WM_GetMinMaxInfo
      LOCAL MinMaxPtr AS Minmaxinfo PTR ' Restrict minimum dialog height
      MinMaxPtr = CBLPARAM ' to avoid corruption
      @MinMaxPtr.ptMinTrackSize.y = 80 ' (of control's DC ?)
      
      END SELECT
      END FUNCTION '
      Great stuff! Many thanks.

      Comment


      • #23
        Hi Dean, Maybe you should digitally sign your programs so that Crowdstrike would not capture it?

        please check this out https://www.davidegrayson.com/signing/

        Comment


        • #24
          Hi Dean, in your post #22 code, it would be better to have double click on the image and then immediately display that image
          something kinda like a toggle switching of image?

          Comment


          • #25
            Hi Dean,

            Try this in your test code..
            Code:
                CASE %WM_LBUTTONDBLCLK
            
                  L_FLIP = NOT L_FLIP
                  IF L_FLIP THEN
                    S_FileName1 = "image_11038.bmp"
                    GRAPHIC BITMAP LOAD S_FileName1, 00, 00 TO hBMP 'put image in memory bitmap
                    GRAPHIC ATTACH CB.HNDL, %IDC_Graphic
                    GRAPHIC STRETCH PAGE hBmp, 0, 0, %HALFTONE ' shortcut, copy complete bitmap to attached target
            
                  ELSE
            
                    S_FileName2 = "image_11043.bmp"
                    GRAPHIC BITMAP LOAD S_FileName2, 00, 00 TO hBMP 'put image in memory bitmap
                    GRAPHIC ATTACH CB.HNDL, %IDC_Graphic
                    GRAPHIC STRETCH PAGE hBmp, 0, 0, %HALFTONE ' shortcut, copy complete bitmap to attached target
            
                  END IF
            Rgds, Dave

            Comment


            • #26
              Hey Dave,

              thanks for the note. I think what I have here works nicely. I trap the notify click on the GR and then issue a macro menu as follows.

              Do I need to delete the old BMP after loading a new one?

              GRAPHIC BITMAP END statement
              Purpose Close the selected graphic bitmap.
              Syntax GRAPHIC BITMAP END
              Remarks You must close every memory bitmap (that was created with GRAPHIC BITMAP LOAD or GRAPHIC BITMAP NEW) when you are finished using them for graphical operations. To close a bitmap, select it with the GRAPHIC ATTACH statement, then execute GRAPHIC BITMAP END.
              See also GRAPHIC ATTACH, GRAPHIC BITMAP LOAD, GRAPHIC BITMAP NEW
              That is, if I load a new one, should I send a GRAPHIC BITMAP END call?

              I added it and also added it at WM_DESTROY, like this:

              Code:
              CASE %WM_DESTROY
              
              IF ISTRUE(hBMP) THEN
              ' Close the selected graphic bitmap
              GRAPHIC BITMAP END
              RESET hBMP
              END IF
              Here is the revised dialog control sequence.

              Again, thank you all!

              Click image for larger version  Name:	Revised Graphic Handler.png Views:	0 Size:	141.4 KB ID:	796475

              Comment


              • #27
                Hi Dean,

                As you noted, you do need to use the GRAPHIC ATTACH statement, then execute GRAPHIC BITMAP END each time you change the image to release system resources.
                Rgds, Dave

                Comment


                • #28
                  just a footnote, on the Graphic Load, you can load it to the resolution you want it at...It will take your full resolution images and on load will vector stretch/reduce to the proper size. I have been able to salvage all my Perfect Sync 2D software by using the embedded PB graphic commands, to create cleaned stretched or reduced bitmaps (which Pefect Sync could not do). I think you can use the Graphic Bitmap Load with the original resolution and the set the desired size on loading...without a Graphic Stretch statement...

                  'writetsbmp

                  GRAPHIC BITMAP LOAD my_original_image,my_x_size_desired,my_y_size_desired,%HALFTONE TO hbmp???
                  GRAPHIC ATTACH hbmp???, 0
                  GRAPHIC SAVE my_resized_image.bmp
                  GRAPHIC BITMAP END

                  'drawfromex (ipltwindowtsplot,xp0,yp0)
                  'stretchbitmapex (ipltwindowtsplot,my_resized_image.bmp,my_x_size_desired,my_y_size_desired

                  Comment

                  Working...
                  X