FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Image x xImage quality difference
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Image x xImage quality difference
Posted: Tue Jun 25, 2024 01:41 PM
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.



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
Posts: 1344
Joined: Wed Nov 16, 2005 09:14 PM
Re: Image x xImage quality difference
Posted: Tue Jun 25, 2024 03:05 PM
Asi es, ximage te da muchas buenas opciones.
Tienes un buen ejemplo en los samples de Fivewin.
ximage01.prg
Code (fw): Select all Collapse
#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

//----------------------------------------------------------------------------//
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Re: Image x xImage quality difference
Posted: Tue Jun 25, 2024 04:22 PM
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.
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Image x xImage quality difference
Posted: Tue Jun 25, 2024 05:08 PM
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 (fw): Select all Collapse
// 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Re: Image x xImage quality difference
Posted: Tue Jun 25, 2024 05:43 PM
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!
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Image x xImage quality difference
Posted: Tue Jun 25, 2024 05:46 PM
Maurício Ventura Faria

P.S. Vai Curinthia!
hahahahahahahaha.

Thamus junthos!!! hahahahahahaha,

Abs.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Image x xImage quality difference
Posted: Thu Jun 27, 2024 04:07 PM
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
Regards



G. N. Rao.

Hyderabad, India
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 12:47 PM
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 (fw): Select all Collapse
#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
Posts: 124
Joined: Mon Nov 14, 2005 10:15 AM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 01:11 PM
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 (fw): Select all Collapse
#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.

[[]]
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 02:50 PM
concentra wrote:
Code (fw): Select all Collapse
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?
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 02:53 PM
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.
Regards



G. N. Rao.

Hyderabad, India
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 03:02 PM
Enrico Maria Giordano wrote:
Code (fw): Select all Collapse
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


Code (fw): Select all Collapse
// 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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 03:07 PM

I tested your sample and found no "white stains" on my result. Do you want to see a screenshot?

Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: Image x xImage quality difference
Posted: Fri Jun 28, 2024 03:11 PM
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.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM