Image x xImage quality difference

Image x xImage quality difference

Postby concentra » Tue Jun 25, 2024 1: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.
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
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Image x xImage quality difference

Postby cmsoft » Tue Jun 25, 2024 3:05 pm

Asi es, ximage te da muchas buenas opciones.
Tienes un buen ejemplo en los samples de Fivewin.
ximage01.prg
Code: Select all  Expand view  RUN
#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

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

User avatar
cmsoft
 
Posts: 1293
Joined: Wed Nov 16, 2005 9:14 pm
Location: Mercedes - Bs As. Argentina

Re: Image x xImage quality difference

Postby concentra » Tue Jun 25, 2024 4: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.
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Image x xImage quality difference

Postby karinha » Tue Jun 25, 2024 5: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: Select all  Expand view  RUN

// 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
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Image x xImage quality difference

Postby concentra » Tue Jun 25, 2024 5: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!
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Image x xImage quality difference

Postby karinha » Tue Jun 25, 2024 5: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
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Image x xImage quality difference

Postby nageswaragunupudi » Thu Jun 27, 2024 4: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Image x xImage quality difference

Postby concentra » 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: Select all  Expand view  RUN

#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
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Image x xImage quality difference

Postby concentra » Fri Jun 28, 2024 1: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: Select all  Expand view  RUN
#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.

[[]]
User avatar
concentra
 
Posts: 124
Joined: Mon Nov 14, 2005 10:15 am
Location: Brazil

Re: Image x xImage quality difference

Postby Enrico Maria Giordano » Fri Jun 28, 2024 2:50 pm

concentra wrote:
Code: Select all  Expand view  RUN
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?
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Image x xImage quality difference

Postby nageswaragunupudi » Fri Jun 28, 2024 2: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
User avatar
nageswaragunupudi
 
Posts: 10690
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Image x xImage quality difference

Postby karinha » Fri Jun 28, 2024 3:02 pm

Enrico Maria Giordano wrote:
concentra wrote:
Code: Select all  Expand view  RUN
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  RUN

// 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
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Image x xImage quality difference

Postby Enrico Maria Giordano » Fri Jun 28, 2024 3:07 pm

I tested your sample and found no "white stains" on my result. Do you want to see a screenshot?
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Image x xImage quality difference

Postby karinha » Fri Jun 28, 2024 3: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
User avatar
karinha
 
Posts: 7872
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil


Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 61 guests