Bugs in TGgiplus

Bugs in TGgiplus

Postby byte-one » Wed Feb 24, 2016 12:27 pm

Code: Select all  Expand view
METHOD New( cFile , cResname ) CLASS GDIBmp
.
.
 IF  FindResource( GetResources(), cResName , 2 )  != 0
             aBmpPal    = PalBmpLoad( cResName )
             // if len(aBmpPal) = 0       -> this line is wrong!!  
             if len(aBmpPal) > 1
              ::hBmp = GdiPlusCreateImageFromRes( aBmpPal[ 1 ], aBmpPal[ 2 ] )
             else
              msginfo( "Recurso no encontrado" )
             endif
         else
.
.
 


In declaration and in code:
Code: Select all  Expand view
//METHOD DrawImage( oBmp,nTop,nleft, nWidth, nHeight ) -> wrong
   METHOD DrawImage( oBmp,nLeft,nTop, nWidth, nHeight )
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Bugs in TGgiplus

Postby byte-one » Sat Feb 27, 2016 7:59 pm

Have anyone see this? (programmer from tgdi-class)
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Bugs in TGgiplus

Postby Antonio Linares » Sat Feb 27, 2016 8:38 pm

Günther,

is it working fine for you with your changes ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42074
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bugs in TGgiplus

Postby cnavarro » Sat Feb 27, 2016 8:45 pm

It is included for the next version

Thanks
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bugs in TGgiplus

Postby byte-one » Sat Feb 27, 2016 9:42 pm

Thanks all!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Bugs in TGgiplus

Postby Silvio.Falconi » Sun Feb 28, 2016 12:23 pm

Strange i use fwh gen release and i use drawimage on my slotmachine application and it seems run ok
perhaphs i change it but i not remember
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7047
Joined: Thu Oct 18, 2012 7:17 pm

Re: Bugs in TGgiplus

Postby ukoenig » Sun Feb 28, 2016 12:43 pm

In case there will be changes

a image is displayed normally from TOP, LEFT but in GDI+ reverse -> LEFT, TOP
As well maybe checking out why deleted on RESIZE ( happens on BUTTONACTION ) ?.

best regards
Uwe :?:
Last edited by ukoenig on Sun Feb 28, 2016 1:11 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bugs in TGgiplus

Postby nageswaragunupudi » Sun Feb 28, 2016 12:48 pm

Mr Antonio and Mr Cristobal

I suggest we may follow standard FWH convention of nTop, nLeft ... etc
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Bugs in TGgiplus

Postby cnavarro » Sun Feb 28, 2016 3:25 pm

nageswaragunupudi wrote:Mr Antonio and Mr Cristobal

I suggest we may follow standard FWH convention of nTop, nLeft ... etc


Mr Rao, these are the change updated

Code: Select all  Expand view


 //----------------------------------------------------------------------------//
 
METHOD DrawImage( oImage, nTop, nLeft, nWidth, nHeight ) CLASS Graphics
 
- if Empty(nWidth ) .or. Empty( nHeight )
-    GdiPlusDrawImage( ::hGraphics, oImage:hBmp, nTop, nLeft )
- else
-    GdiPlusDrawImage(  ::hGraphics, oImage:hBmp,nTop,nLeft, nWidth, nHeight )
-endif

+  if Empty( nWidth ) .or. Empty( nHeight )
+     GdiPlusDrawImage( ::hGraphics, oImage:hBmp, nLeft, nTop )
+  else
+     GdiPlusDrawImage(  ::hGraphics, oImage:hBmp, nLeft, nTop, nWidth, nHeight )
+  endif
 
 Return nil

 


an this is function GdiPlusDrawImage

Code: Select all  Expand view


HB_FUNC( GDIPLUSDRAWIMAGE )
{

.../...

   switch (iParams){

    case 4:
      nLeft = hb_parni( 3 );
      nTop = hb_parni( 4 );

    graphics->DrawImage( newImage, nLeft, nTop );

   case 6:
     nLeft = hb_parni( 3 );
     nTop = hb_parni( 4 );
     nWidth =  hb_parni( 5 );
     nHeight = hb_parni( 6 );

    graphics->DrawImage( newImage, nLeft, nTop, nWidth, nHeight );  //Rect object whose x-coordinate, y-coordinate, width, and height

  }

}

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bugs in TGgiplus

Postby ukoenig » Sun Feb 28, 2016 5:44 pm

I created a little testtool to add multiple images.

there is a problem :
1. Image added ON PAINT
2. and 3. image added on button-action
changing the background, only the image painted with button 2 stays visible.
The transparent-painting is OK.
is there a possible solution to keep ALL images visible ?
The same happens on RESIZE

DOWNLOAD
http://www.pflegeplus.com/DOWNLOADS/Gdiplus3.zip

Image

best regards
Uwe :?:
Last edited by ukoenig on Sun Feb 28, 2016 11:35 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bugs in TGgiplus

Postby cnavarro » Sun Feb 28, 2016 7:21 pm

Uwe, try this
I do not know if I understand your problem

Code: Select all  Expand view


#include "FiveWin.ch"
#include "constant.ch"

Static c_Path
Static c_Path1

Function Main()

   local oWnd
   local oBtn[10]
   local oTextFont
   local cImage    := "Logo.png"
   local nLeft     := 10
   local nTop      := 10
   local oBmp
   local oImg1
   local oImg2
   local oImg3
   local lIni      := .T.

   c_Path  := cFilePath(GetModuleFileName( GetInstance() ) )
   c_Path1 := c_Path + "IMAGES\"

   DEFINE IMAGE oBmp FILENAME c_path1 + "
Back.png"

   oTextFont := TFont():New( "
Arial", 0, 20,.F.,.F.,  0,  0,  0,.F.,.F.)

   DEFINE WINDOW oWnd  FROM 10, 10 TO 700, 900 TITLE "
GDI+ TEST" PIXEL // ;
      // STYLE WS_POPUP BRUSH oBrush1
   oWnd:bRClicked := {|| oWnd:End() }

   @ oWnd:nHeight - 100, oWnd:nWidth - 370 BTNBMP oBtn[1] SIZE 100, 50 OF oWnd  2007 ;
      FILENAME c_path1 + "
Paint.bmp" ;
      LEFT ;
      PROMPT "
&Paint 1" ;
      FONT oTextFont ;
      ACTION ( cImage := "
Logo.png", ; //nLeft := 500, nTop := 10, ;
               oImg1  := DRAWIMAGE(oWnd, cImage, 500, 10 ) )
      oBtn[1]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
        { { 0.5, 10526975, 16777215 }, ;
          { 0.5, 16777215, 10526975 } }, ;
        { { 0.5, 16768185, 16777215 }, ;
           { 0.5, 16777215, 16768185  } } ) }
      oBtn[1]:nLayout := 2
      oBtn[1]:SetColor( 128 )
      oBtn[1]:cTooltip :=  { "
Exit" + CRLF + ;
                             "
GDI-test","EXIT", 1, CLR_BLACK, 14089979 }

   @ oWnd:nHeight - 100, oWnd:nWidth - 260 BTNBMP oBtn[2] SIZE 100, 50 OF oWnd  2007 ;
      FILENAME c_path1 + "
Paint.bmp" ;
      LEFT ;
      PROMPT "
&Paint 2" ;
      FONT oTextFont ;
      ACTION ( cImage := "
Logo.png", ; //nLeft := 250, nTop := 250, ;
               oImg2  := DRAWIMAGE( oWnd, "
Logo.png", 250, 250 ) )
      oBtn[2]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
        { { 0.5, 10526975, 16777215 }, ;
          { 0.5, 16777215, 10526975 } }, ;
        { { 0.5, 16768185, 16777215 }, ;
           { 0.5, 16777215, 16768185  } } ) }
      oBtn[2]:nLayout := 2
      oBtn[2]:SetColor( 128 )
      oBtn[2]:cTooltip :=  { "
Image 2" + CRLF + ;
                             "
test","TEST", 1, CLR_BLACK, 14089979 }
     
// -------------

@ oWnd:nHeight - 100, 20 BTNBMP oBtn[6] SIZE 110, 50 OF oWnd  2007 ;
FILENAME c_path1 + "
Color.bmp" ;
LEFT ;
PROMPT "
&Color" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 1, 3194624 )
oBtn[6]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 16765863, 16777215 }, ;
      { 0.5, 16777215, 16765863 } }, ;
    { { 0.5, 16768185, 16777215 }, ;
       { 0.5, 16777215, 16768185  } } ) }
oBtn[6]:nLayout := 2
oBtn[6]:SetColor( 128 )
oBtn[6]:cTooltip :=  { "
use color" + CRLF + ;
                                        "
Background","COLOR", 1, CLR_BLACK, 14089979 }

@ oWnd:nHeight - 100, 135 BTNBMP oBtn[7] SIZE 110, 50 OF oWnd  2007 ;
FILENAME c_path1 + "
Gradient.bmp" ;
LEFT ;
PROMPT "
&Gradient" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 2, 16762767, 16773088, .T., 0.5 )
oBtn[7]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 16765863, 16777215 }, ;
      { 0.5, 16777215, 16765863 } }, ;
    { { 0.5, 16768185, 16777215 }, ;
       { 0.5, 16777215, 16768185  } } ) }
oBtn[7]:nLayout := 2
oBtn[7]:SetColor( 128 )
oBtn[7]:cTooltip :=  { "
use Gradient" + CRLF + ;
                                        "
Background","GRADIENT", 1, CLR_BLACK, 14089979 }

@ oWnd:nHeight - 100, 250 BTNBMP oBtn[8] SIZE 110, 50 OF oWnd  2007 ;
FILENAME c_path1 + "
Brush.bmp" ;
LEFT ;
PROMPT "
&Brush" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 3, , , , , "
Brush.bmp" )
oBtn[8]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 16765863, 16777215 }, ;
      { 0.5, 16777215, 16765863 } }, ;
    { { 0.5, 16768185, 16777215 }, ;
       { 0.5, 16777215, 16768185  } } ) }
oBtn[8]:nLayout := 2
oBtn[8]:SetColor( 128 )
oBtn[8]:cTooltip :=  { "
use Brush" + CRLF + ;
                                        "
Background","BRUSH", 1, CLR_BLACK, 14089979 }


@ oWnd:nHeight - 100, 365 BTNBMP oBtn[9] SIZE 110, 50 OF oWnd  2007 ;
FILENAME c_path1 + "
Image.bmp" ;
LEFT ;
PROMPT "
&Image" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 4, , , , , ,"
Backgrd.jpg" )
oBtn[9]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 16765863, 16777215 }, ;
      { 0.5, 16777215, 16765863 } }, ;
    { { 0.5, 16768185, 16777215 }, ;
       { 0.5, 16777215, 16768185  } } ) }
oBtn[9]:nLayout := 2
oBtn[9]:SetColor( 128 )
oBtn[9]:cTooltip :=  { "
use Image" + CRLF + ;
                                        "
Background","IMAGE", 1, CLR_BLACK, 14089979 }


@ oWnd:nHeight - 100, oWnd:nWidth - 150 BTNBMP oBtn[10] SIZE 100, 50 OF oWnd  2007 ;
FILENAME c_path1 + "
Exit.bmp" ;
LEFT ;
PROMPT "
&Exit" ;
FONT oTextFont ;
ACTION oWnd:End()
oBtn[10]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 10526975, 16777215 }, ;
      { 0.5, 16777215, 10526975 } }, ;
    { { 0.5, 16768185, 16777215 }, ;
       { 0.5, 16777215, 16768185  } } ) }
oBtn[10]:nLayout := 2
oBtn[10]:SetColor( 128 )
oBtn[10]:cTooltip :=  { "
Exit" + CRLF + ;
                        "
GDI-test","EXIT", 1, CLR_BLACK, 14089979 }

//oWnd:bPainted := {|| DRAWIMAGE(oWnd, cImage, nLeft, nTop ) }

ACTIVATE WINDOW oWnd CENTER ;
ON INIT ( oImg3 := DRAWIMAGE( oWnd, cImage, nLeft, nTop ) ) ;
ON PAINT ( ABPaint( oWnd:hDC, 30, 30, oBmp:hBitmap, 255 ), ;
           if( !lIni, ( DrawImage( oWnd, oImg1, 500, 10 ),;
                        DrawImage( oWnd, oImg2, 250, 250 ),;
                        DrawImage( oWnd, oImg3, nLeft, nTop ) ), lIni := .F. ) ) //;          
oTextFont:End()

RETURN NIL

// -------------

FUNCTION DRAWIMAGE( oWnd, cImage, nLeft, nTop )
   
   local hDC       := oWnd:GetDc()
   local cNew
   local oGraphics := Graphics():New( oWnd:hDC )
   local oImage
   if Valtype( cImage ) = "
C"
      cNew      := c_Path1 + cImage
      oImage    := GDIBmp():New( cNew )  
   else
      oImage    := cImage
   endif
   if !Empty( oImage )
      oGraphics:DrawImage( oImage, nTop, nLeft  ) //, nTop )
      oGraphics:Destroy()
   endif
   oWnd:ReleaseDc()

Return oImage

// --------  Background ---------------

FUNCTION DRAW_BACK( oWnd, nStyle, nColor1, nColor2, lDirect, nMove, cBrush, cImage )

   local hDC
   local oBrush
   local oImage
   local aGrad
   local aRect   := GETCLIENTRECT( oWnd:hWnd )
   local hBmp
   local hBmpOld

   IF nStyle = 1 // COLOR
    DEFINE BRUSH oBrush COLOR nColor1
   ENDIF
   IF nStyle = 2 // GRADIENT
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    hDC = CreateCompatibleDC( oWnd:GetDC() )
    hBmp = CreateCompatibleBitMap( oWnd:hDC, aRect[4], aRect[3] )
    hBmpOld = SelectObject( hDC, hBmp )
    GradientFill( hDC, 0, 0, aRect[3], aRect[4], aGrad, lDirect )
    oBrush := TBrush():New( ,,,, hBmp )
    oBrush:Cargo  := aGrad
    SelectObject( hDC, hBmpOld )
    ReleaseDC(hDC)
   ENDIF
   IF nStyle = 3 // BMP-BRUSH
    IF FILE( c_path1 + cBrush )
        DEFINE BRUSH oBrush FILE c_path1 + cBrush
    ELSE
        IF !EMPTY(cImage)
            MsgAlert( "
File : " + cBrush + CRLF + ;
                    "
does not exist" + CRLF + ;
                        "
to create Background !", "ATTENTION" )
        ENDIF
    ENDIF
   ENDIF
   IF nStyle = 4 // Image ADJUSTED
    IF FILE( c_path1 + cImage )
        DEFINE IMAGE oImage FILE c_path1 + cImage
        oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) )
        oImage:End()
    ELSE
        IF !EMPTY(cImage)
            MsgAlert( "
File  : " + cImage + CRLF + ;
                       "
does not exist" + CRLF + ;
                           "
to create Background !", "ATTENTION" )
        ENDIF
    ENDIF
   ENDIF
   oWnd:Setbrush( oBrush )
   oBrush:End()
   
RETURN( NIL)  



Please, change for your test

Code: Select all  Expand view

      oGraphics:DrawImage( oImage, nTop, nLeft  ) //, nTop )
 


with

Code: Select all  Expand view

      oGraphics:DrawImage( oImage, nLeft, nTop )
 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bugs in TGgiplus

Postby ukoenig » Sun Feb 28, 2016 8:08 pm

Cristobal,

it comes close to the solution I'm looking for.
Windows-resize and multiple image-painting is working now.
Still I have to do some finetuning and I will add a new Download-link

thank You very much

best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Bugs in TGgiplus

Postby cnavarro » Sun Feb 28, 2016 8:14 pm

I'm working on making a proportional resize the images to resize we do in Windows, but so far without success

Regards
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bugs in TGgiplus

Postby cnavarro » Sun Feb 28, 2016 8:25 pm

ukoenig wrote:Cristobal,

it comes close to the solution I'm looking for.
Windows-resize and multiple image-painting is working now.
Still I have to do some finetuning and I will add a new Download-link

thank You very much

best regards
Uwe :D


Please, modify my code, add clausule VALID ( End objects )

Code: Select all  Expand view


   ACTIVATE WINDOW oWnd CENTER ;
      ON INIT ( oImg3 := DrawImage( oWnd, cImage, nLeft, nTop ) ) ;
      ON PAINT ( ABPaint( oWnd:hDC, 30, 30, oBmp:hBitmap, 255 ), ;
                 if( !lIni, ( DrawImage( oWnd, oImg1, 500, 10 ),;
                              DrawImage( oWnd, oImg2, 250, 250 ),;
                              DrawImage( oWnd, oImg3, nLeft, nTop ) ), lIni := .F. ) ) ;
      VALID ( if( !Empty( oImg1 ), oImg1:End(), ), ;
              if( !Empty( oImg2 ), oImg2:End(), ), ;
              if( !Empty( oImg3 ), oImg3:End(), ), ;
              .T. )

 
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Bugs in TGgiplus

Postby ukoenig » Sun Feb 28, 2016 11:38 pm

Christobal,

I completed the TESTTOOL
Now RESIZE and BACKGROUND-change works perfect.
Tomorrow I will add a new DOWNLOAD

Image

Thank You very much for Your help

best regards
Uwe :D
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Natter and 69 guests