Procedure FullView (cFile ) function DC_GetWorkArea()

This forum is for eXpress++ general support.
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#11 Post by Eugene Lutsenko »

Now everything works correctly and accurately. What would I do without you? Thank you!

Now the procedure FullView( cFile, mPar) took the form:

Code: Select all

***********************************************************************
/*
 * This procedure displays an image file in a separate window
 */
***********************************************************************
PROCEDURE FullView( cFile, mPar )

   LOCAL oDlg, oImage, oPS, aSize, aPos
   LOCAL lBGClr := XBPSYSCLR_TRANSPARENT

  /*
   * Only bitmap and meta files are supported
   */
   IF cFile <> NIL            .AND. ;
     ( ".BMP" $ Upper( cFile ) .OR. ;
       ".EMF" $ Upper( cFile ) .OR. ;
       ".GIF" $ Upper( cFile ) .OR. ;
       ".JPG" $ Upper( cFile ) .OR. ;       
       ".PNG" $ Upper( cFile ) .OR. ;
       ".MET" $ Upper( cFile )      )

     /*
      * Create hidden dialog window
      */
      oDlg := XbpDialog():new( AppDesktop(),,,{100,100} )
      oDlg:taskList   := .F.
      oDlg:visible    := .F.
      oDlg:title      := cFile
      oDlg:sizeRedraw := .T.
      oDlg:close      := {|mp1,mp2,obj| obj:destroy() }
      oDlg:alwaysOnTop := .T.                                // Выводить изображение на переднем плане
      oDlg:create()

     /*
      * Create a presentation space and connect it with the device
      * context of :drawingArea
      */
      oPS := XbpPresSpace():new():create( oDlg:drawingArea:winDevice() )

      IF ".BMP" $ Upper( cFile ) .OR. ;
         ".GIF" $ Upper( cFile ) .OR. ;
         ".JPG" $ Upper( cFile ) .OR. ;       
         ".PNG" $ Upper( cFile )

        /*
         * File contains a bitmap. Limit the window size to a range
         * between 16x16 pixel and the screen resolution
         */
         oImage   := XbpBitmap():new():create( oPS )
         oImage:loadFile( cFile )

         IF oImage:transparentClr <> GRA_CLR_INVALID
            lBGClr := XBPSYSCLR_DIALOGBACKGROUND
         ENDIF

         *************** ЗДЕСЬ ВЗЯТЬ ОПРЕДЕЛЕННЫЕ ВЫШЕ РАЗМЕРЫ ИЗОБРАЖЕНИЯ <<<===##########################

         aSize    := { oImage:xSize, oImage:ySize }

         aSize[1] := Max( 16, Min( aSize[1], AppDeskTop():currentSize()[1] ) )
         aSize[2] := Max( 16, Min( aSize[2], AppDeskTop():currentSize()[2] ) )
         aSize    := oDlg:calcFrameRect( {0,0, aSize[1], aSize[2]} )

         oDlg:setSize( {aSize[3], aSize[4]} )

         /*
          * The window must react to xbeP_Paint to redraw the bitmap
          */
         oDlg:drawingarea:paint := {|x,y,obj| x:=obj:currentSize(), ;
                                     oImage:draw( oPS, {0, 0, x[1], x[2]}, ;
                                     {0, 0, oImage:xSize, oImage:ySize},,;
                                     GRA_BLT_BBO_IGNORE), Sleep(0.1) }
      ELSE
        /*
         * Display a meta file. It has no size definition for the image
         */
         oImage := XbpMetafile():new():create()
         oImage:load( cFile )
         aSize := { 600, 400 }
         oDlg:setSize( aSize )
         oDlg:drawingarea:paint := {|x,y,obj| x:=obj:currentSize(), ;
                                              oImage:draw( oPS, {0, 0, x[1], x[2]}),;
                                              Sleep(0.1) }
         lBGClr := XBPSYSCLR_DIALOGBACKGROUND
      ENDIF

     /*
      * Set the background color for the dialog's drawingarea.
      * Per default, the transparent color is used to avoid 
      * flicker during refreshs. For transparent images and 
      * metafiles, however, color gray is set instead, see above. 
      * This is done to prevent bits of the desktop from being
      * visible in transparent areas of the bitmap/metafile image.
      * Alternatively, transparency could be explicitly switched
      * off for bitmapped images.
      */
      oDlg:drawingArea:SetColorBG( lBGClr )

     /*
      * Display the window centered on the desktop
      */
      DO CASE
         CASE mPar = "по верху"
              AlignWindow( oDlg )
         CASE mPar = "по центру"
              aPos:= CenterPos( oDlg:currentSize(), AppDesktop():currentSize() )
              oDlg:setPos( aPos )
      ENDCASE

      oDlg:show()
      SetAppFocus( oDlg )
* ------------------------------------------------------------- *
*     Правильная реакция на Esc от Джимми
* ------------------------------------------------------------- *
      // add this
      nEvent := 0
      DO WHILE nEvent != xbeP_Close
         nEvent := APPEVENT( @mp1, @mp2, @oXbp )
         IF nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC 
            oDlg:destroy()
            Exit
         ELSE
            oXbp:HandleEvent( nEvent, mp1, mp2 )
         ENDIF
      ENDDO
* ------------------------------------------------------------- *
   ENDIF
RETURN
******************************************************************************************
******** Выравнивание вывода в FullView() по верхнему краю без панели задач **************
******************************************************************************************
FUNCTION AlignWindow( oDlg )  

LOCAL aCoords := DC_GetWorkArea(), nBottom, nLeft

nBottom := AppDeskTop():currentSize()[2] - aCoords[4]
nLeft := AppDeskTop():currentSize()[1]/2 - oDlg:currentSize()[1]/2

oDlg:setPos({nLeft,nBottom})

RETURN nil
[/size]

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#12 Post by Eugene Lutsenko »

I took this decision when developing new versions functions: F4_4_8(), F4_4_9(), F4_4_10(), F4_4_11(), F4_4_12(): http://lc.kubagro.ru/__AIDOS-X.txt. There are many more. I will slowly implement.

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#13 Post by Eugene Lutsenko »

I noticed that the BMP2BMP() function provides a very low quality of scaling. In other words, the scaled file is very damaged. If the original quality scale file is scaled using the image viewer, the quality is much higher. Is it possible to improve the quality of the resized using BMP 2 BMP() of the file?

User avatar
Auge_Ohr
Posts: 1428
Joined: Wed Feb 24, 2010 3:44 pm

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#14 Post by Auge_Ohr »

Eugene Lutsenko wrote:I noticed that the BMP2BMP() function provides a very low quality of scaling.
hm ... :think:

Code: Select all

FUNCTION BMP2BMP( oBMP, aXbpSize )

  oHuge:Draw( oPS, { 0, 0, aXbpSize[1], aXbpSize[2] },,,GRA_BLT_BBO_IGNORE  )

PROCEDURE FullView( cFile )

  oImage:draw( oPS, {0, 0, x[1], x[2]}, ;
                    {0, 0, oImage:xSize, oImage:ySize},,;
                     GRA_BLT_BBO_IGNORE)
both Function do exact the same so there can not be a difference :snooty:
! Note : always use Original oBMP ... not a Copy from Copy

Question : how big is your Original Image and which Size your (bad) Result :?:

i Note that some Image look bad when reduce Size. it never happens when upsize a Image.
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#15 Post by Eugene Lutsenko »

Perhaps I do scaling two times: using BMP 2 BMP (), and then another using FullView (). I'll figure it out later

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Procedure FullView (cFile ) function DC_GetWorkArea()

#16 Post by Eugene Lutsenko »

Yes, indeed the procedure FullView() itself provides a scale. However, this is not always necessary. The fact is that you get a different result if you scale the image in bmp 2 bmp() and then display it with FullView(), or if you display the original non-scaled image with FullView (). This is because in bmp 2 bmp() I set the scaled image size myself, and in FullView () they are determined automatically by the screen size. I came to the conclusion that on a high resolution monitor, I immediately display the original image without scaling with FullView(). And on low-resolution monitors, I first scale the image using bmp 2 bmp () and then display it without scaling using FullView (). So it turns out better the location of the window (more user friendly). So I have enabled the option to disable scaling in FullView().

Post Reply