Page 1 of 2

Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 1:41 pm
by concentra
Hi.
I noted a difference in quality between Image and xImage controls.
In the below samples, the first one is an Image and the last is a xImage.
Image
Image

And the original image is this Tiff image http://farmacia.com.br/lixo/Image.tif.
xImage has many more options to manipulate images and I would like to use it.
My question is, is it possible to use a xImage control with an Image object ?
I don't need to edit the image, only show, rotate, zoom, move, etc...
I saw that xImage can be used with EMF and WMF meta files, is this a way ?
Does any one can point me the path ?

Regards,
Maurício Ventura Faria

Re: Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 3:05 pm
by cmsoft
Asi es, ximage te da muchas buenas opciones.
Tienes un buen ejemplo en los samples de Fivewin.
ximage01.prg
Code: Select all  Expand view
#include "fivewin.ch"

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

function Main()

   local aImages, oWnd, oFont, oBrush, oBrw, oImage

   FW_SetUnicode( .t. )
   HB_SETCODEPAGE( "UTF8" ) // Harbour (not xHarbour) to display unicode filenames

   aImages  := ReadFolder()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-15
   DEFINE BRUSH oBrush FILE "..\bitmaps\backgrnd\stone.bmp"
   DEFINE WINDOW oWnd
   oWnd:SetFont( oFont )

   DEFINE BUTTONBAR oWnd:oBar SIZE 100,32 2007
   SET MESSAGE OF oWnd TO "" 2007

   DEFINE BUTTON OF oWnd:oBar PROMPT "Center"     CENTER ACTION ( oImage:Center(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Width"  CENTER ACTION ( oImage:FitWidth(),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Height" CENTER ACTION ( oImage:FitHeight(), oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Fit Rect"   CENTER ACTION ( oImage:FitRect(),   oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Rotate"     CENTER ACTION ( oImage:Rotate(),    oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Zoom"       CENTER ACTION ( MsgInfo( "Zoom/Unzoom with Mouse Wheel" ),  oImage:SetFocus() )
   DEFINE BUTTON OF oWnd:oBar PROMPT "Pan/Move"   CENTER ACTION ( MsgInfo( "Drag with Mouse" ),  oImage:SetFocus() )


   @ oWnd:oBar:nHeight,0 XBROWSE oBrw SIZE 300,-oWnd:oMsgBar:nHeight ;
      PIXEL OF oWnd DATASOURCE aImages COLUMNS 1 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol   := 1
      :bChange       := { || oImage:Refresh() }
      //
      :CreateFromCode()
   END

   @ oWnd:oBar:nHeight,300 XIMAGE oImage SIZE 0,-oWnd:oMsgBar:nHeight ;
      OF oWnd SOURCE MEMOREAD( oBrw:aRow[ 2 ] )

   oImage:SetBrush( oBrush )

   WITH OBJECT oWnd
      :nWidth     := ScreenWidth()  * 0.6
      :nHeight    := ScreenHeight() * 0.6
   END

   ACTIVATE WINDOW oWnd CENTERED
   RELEASE FONT oFont
   RELEASE BRUSH oBrush


return nil

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

static function ReadFolder

   local aImages  := {}
   local aSub     := { "AlphaBmp\", "hires\", "pngs\" }
   local c, cPath, aDir

   for each c in aSub
      cPath    := "
..\bitmaps\" + c
      aDir     := Directory( cPath + "
*.*" )
      AEval( aDir, { |a| If( a[ 2 ] > 32000, AAdd( aImages, { a[ 1 ], TrueName( cPath + a[ 1 ] ) } ), nil ) } )
   next

   ASort( aImages,,,{ |x,y| Lower( x[ 1 ] ) < Lower( y[ 1 ] ) } )

return aImages

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


Re: Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 4:22 pm
by concentra
cmsoft wrote:Asi es, ximage te da muchas buenas opciones.

Yes, I am aware of that.
My question is about quality of the image on screen.
And xImage is worse than Image for the same TIF image file.

Re: Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 5:08 pm
by karinha
Concentra, compare você mesmo. Eu prefiro usar IMAGE.

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=38015&p=227197&hilit=DEFINE+XIMAGE&sid=0421d344f99be58a2c11d1c9357e57c3&sid=d5d5c58fa250fd1f70479ca6a04c4f8d#p227197

https://www.fivetechsoft.com/forums/viewtopic.php?t=37301

https://www.fivetechsoft.com/forums/viewtopic.php?t=37389

Code: Select all  Expand view

// C:\FWH\SAMPLES\TESTIMG2.PRG

#include "FiveWin.ch"

FUNCTION Main()

   LOCAL oDlg, oImage

   DEFINE DIALOG oDlg SIZE 800, 600 PIXEL TRUEPIXEL RESIZABLE TITLE "XIMAGE"

   @ 00, 30 BUTTON "SELECT" SIZE 80, 30 PIXEL OF oDlg ACTION SetImage( oImage )

   @ 50, 30 XIMAGE oImage SIZE 500, 500 OF oDlg

   oImage:lCanPaste  := .T.

   ACTIVATE DIALOG oDlg CENTERED

RETURN NIL

FUNCTION SetImage( oImage )

   LOCAL cFile := cGetFile( "|*.tif|" )
   LOCAL hIco, hBmp

   oImage:SetSource( cFile )

RETURN NIL

/*
FUNCTION Main() // usando IMAGE

   LOCAL oDlg, oImg

   // DEFINE IMAGE oImg FILENAME "..\bitmaps\olga1.jpg"
   DEFINE IMAGE oImg FILENAME "image.tif"

   DEFINE DIALOG oDlg TITLE "Image background"

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oDlg:SetSize( oImg:nWidth, oImg:nHeight ), oDlg:Center() ) ;
      ON PAINT PalBmpDraw( hDC, 0, 0, oImg:hBitmap )

   oImg:End()

RETURN NIL
*/

 


Regards, saludos.

Re: Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 5:43 pm
by concentra
karinha wrote:Concentra, compare você mesmo. Eu prefiro usar IMAGE.

Então Karinha, comparei...
Image tem melhor qualidade na tela ( preciso disso ) e xImage tem mais recursos e funções.
No final acho que vou usar o Image e "chupar" as funções da classe xImage que eu preciso.

[[]]
Maurício Ventura Faria

P.S. Vai Curinthia!

Re: Image x xImage quality difference

PostPosted: Tue Jun 25, 2024 5:46 pm
by karinha
Maurício Ventura Faria

P.S. Vai Curinthia!


hahahahahahahaha.

Thamus junthos!!! hahahahahahaha,

Abs.

Regards, saludos.

Re: Image x xImage quality difference

PostPosted: Thu Jun 27, 2024 4:07 pm
by nageswaragunupudi
And the original image is this Tiff image http://farmacia.com.br/lixo/Image.tif.

I am not able to get the image from this address.
Can you make this image available to me please?
I would like to test with TImage and TXImage and see what can be done to improve the quality.
Or if possible can you send the Tif file to my email
nageswaragunupudi [at] gmail [dot] com

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 12:47 pm
by concentra
nageswaragunupudi wrote:
And the original image is this Tiff image http://farmacia.com.br/lixo/Image.tif.

I am not able to get the image from this address.

This is kind of weird. The image is there...
if possible can you send the Tif file to my email
nageswaragunupudi [at] gmail [dot] com

Sent.

See a sample test code:

Code: Select all  Expand view

#include "Fivewin.ch"

FUNCTION MAIN()

   Local oWnd
   LOCAL oImage
   LOCAL oXImage

   PARAMETER cFile

   IF EMPTY(cFile)
      cFile := "Image.tif"
   ENDIF

   DEFINE WINDOW oWnd FROM 1,1 TO GetSysMetrics(1)-400,GetSysMetrics(0)-1200 TITLE "FiveWin Images" PIXEL

   @ 1,1 IMAGE oImage SIZE (oWnd:nWidth/2)-30,oWnd:nHeight-90 FILE cFile OF oWnd
   oImage:nZoom := ( (oWnd:nWidth/2)-30 ) / nBmpWidth( oImage:hBitmap )

   @ 14,(GetSysMetrics(0)-1200)/2 XIMAGE oXImage SIZE (oWnd:nWidth/2)-30,oWnd:nHeight-90  FILE cFile OF oWnd
   oXImage:FitWidth()

   ACTIVATE WINDOW oWnd

   oImage:End()

Return nil
 


[[]] Maurício Ventura Faria

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 1:11 pm
by concentra
nageswaragunupudi wrote:I would like to test with TImage and TXImage and see what can be done to improve the quality.


Take a look at this code:

Code: Select all  Expand view
#include "Fivewin.ch"

FUNCTION MAIN()

   Local oWnd
   LOCAL oImage
   LOCAL oImage2
   LOCAL oXImage

   PARAMETER cFile

   IF EMPTY(cFile)
      cFile := "Image.tif"
   ENDIF

   DEFINE WINDOW oWnd FROM 1,1 TO GetSysMetrics(1)-400,GetSysMetrics(0)-1200 TITLE "FiveWin Images" PIXEL

   @ 1,1 IMAGE oImage SIZE (oWnd:nWidth/2)-30,oWnd:nHeight-90 FILE cFile OF oWnd
   oImage:nZoom := ( (oWnd:nWidth/2)-30 ) / nBmpWidth( oImage:hBitmap )


   oImage2 := TImage():New(,,,,, cFile, .F., oWnd,,, .F., .F.,,, .F.,, .F.,, .F., "oImage2" )

   @ 14,(GetSysMetrics(0)-1200)/2 XIMAGE oXImage SIZE (oWnd:nWidth/2)-30,oWnd:nHeight-90  SOURCE oImage2:hBitmap  OF oWnd
   oXImage:FitWidth()

   ACTIVATE WINDOW oWnd

   oImage:End()

Return nil


I don't know if it helps...
If I am correct, I took the handle of an Image object and used it as source of a xImage object and the quality in the screen are is the same.
This make me thinking that the issue can be only when showing the image on screen.

[[]]

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 2:50 pm
by Enrico Maria Giordano
concentra wrote:
Code: Select all  Expand view
PARAMETER cFile


This is a very old statement that you should never use anymore. Replace it with a LOCAL statement. Anyway, I just tested your sample with XIMAGE and found no difference between the results using IMAGE and XIMAGE. How to reproduce the problem?

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 2:53 pm
by nageswaragunupudi
with XIMAGE and found no difference between the results using IMAGE and XIMAGE. How to reproduce the problem?


I noticed some issues with regards to the Tif file he sent me. I am working on it.

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 3:02 pm
by karinha
Enrico Maria Giordano wrote:
concentra wrote:
Code: Select all  Expand view
PARAMETER cFile


This is a very old statement that you should never use anymore. Replace it with a LOCAL statement. Anyway, I just tested your sample with XIMAGE and found no difference between the results using IMAGE and XIMAGE. How to reproduce the problem?


Enrico,

https://imgur.com/tpksOVk

Image

Code: Select all  Expand view

// C:\FWH\SAMPLES\CONCENT4.PRG

#Include "Fivewin.ch"

STATIC oWnd

FUNCTION Main()

   LOCAL oImage, oXImage, cFile := "Image.tif", oSay, oSay2

   DEFINE WINDOW oWnd FROM 1, 1 TO GetSysMetrics(1)-100, GetSysMetrics(0)-200 ;
      TITLE "FiveWin Images" PIXEL

   @ 1, 1 SAY oSay PROMPT "This a Test: IMAGE" OF oWnd SIZE 140, 12 UPDATE ;
      COLOR CLR_RED TRANSPARENT ADJUST

   @ 3, 1 IMAGE oImage SIZE ( oWnd:nWidth / 2 ) - 30, oWnd:nHeight - 90 ;
      FILE cFile OF oWnd // ADJUST

   oImage:nZoom := ( ( oWnd:nWidth / 2 ) - 30 ) / nBmpWidth( oImage:hBitmap )

   oImage:lTransparent := .T.

   @ 1, 69 SAY oSay2 PROMPT "This a Test: XIMAGE" OF oWnd SIZE 140, 12 UPDATE ;
      COLOR CLR_RED TRANSPARENT ADJUST

   @ 40, ( GetSysMetrics( 0 ) - 200 ) / 2 XIMAGE oXImage ;
      SIZE ( oWnd:nWidth / 2 ) - 30, oWnd:nHeight - 90   ;
      FILE cFile OF oWnd UPDATE // NOBORDER

   oXImage:FitWidth()

   oXImage:nUserControl := 0
   oXImage:Shadow()

   oXImage:lTransparent := .T.

   ACTIVATE WINDOW oWnd CENTERED

   oImage:End()

RETURN NIL

// FIN / END
 


Regards, saludos.

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 3:07 pm
by Enrico Maria Giordano
I tested your sample and found no "white stains" on my result. Do you want to see a screenshot?

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 3:11 pm
by karinha
Enrico Maria Giordano wrote:I tested your sample and found no "white stains" on my result. Do you want to see a screenshot?


Yes please.

Gracias, tks.

Regards, saludos.

Re: Image x xImage quality difference

PostPosted: Fri Jun 28, 2024 3:26 pm
by Enrico Maria Giordano