Page 1 of 1

Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Tue Jun 11, 2019 4:24 pm
by AngelSalom
Hola amigos, acabo de actualizar a fwh 19.05 y estoy tratando de decidir cual es la mejor forma de mostrar imágenes en los diálogos.
Actualmente trabajo con una variante de tImage (tZoomImage) adaptada por Jaime Irurzun y que consigue ajustar la imagen de forma proporcional.
He probado la clase tImage en la versión actual y sigue sin ajustar de forma proporcional la imagen.
La pregunta es, ¿sigo usando tZoomimage o hay alguna clase (he visto xImage) propia de FW que ajuste de forma proporcional las imagenes?

Gracias!

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Tue Jun 11, 2019 7:15 pm
by nageswaragunupudi
XImage.

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Tue Jun 11, 2019 8:36 pm
by AngelSalom
Gracias, primer problema (o desconocimiento) con xImage.
Cuando se crea desde recurso no hace caso a las llamadas a bRClicked o bLClicked (ni tan sólo muestra su propio menú pop).
Code: Select all  Expand view
#include "fivewin.ch"

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

function Main()

   Local oDlg, oImage

   // Funciona bien
   DEFINE DIALOG oDlg FROM 0,0 TO 40,40
   @ 0,0 XIMAGE oImage FILE "image.jpg" SIZE 0,0 OF oDlg
   oImage:bRClicked:={|| MsgInfo ('Hola')}
   ACTIVATE DIALOG oDlg CENTERED
   
  // No funciona el menú ni evalua mi bRClicked si lo defino
   DEFINE DIALOG oDlg RESOURCE "Dialogo"
   REDEFINE XIMAGE oImage ID 4001 OF oDlg FILE "image.jpg"
   oImage:bRClicked:={|| MsgInfo ('Hola')}
   ACTIVATE DIALOG oDlg CENTERED

return nil

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


El fichero rc
Code: Select all  Expand view
// RESOURCE SCRIPT generated by "Pelles C for Windows, version 9.00".

#include <windows.h>
#include <commctrl.h>
#include <richedit.h>

LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US

DIALOGO DIALOG DISCARDABLE 0, 0, 567, 274
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "Test"
FONT 8, "MS Sans Serif"
{
  CONTROL "", 4001, "Static", SS_BITMAP|SS_CENTERIMAGE|WS_BORDER, 0, 1, 567, 232
}

 

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Wed Jun 12, 2019 1:37 am
by nageswaragunupudi
It works, if we change the rc file like this:
Code: Select all  Expand view
FONT 8 , "MS Sans Serif"
{
  CONTROL "", 4001, "TXImage", WS_CHILD | WS_TABSTOP | WS_VISIBLE, 0, 0, 567, 232

}


With XImage, by default, the user can move the image by mouse-drag, zoom and unzoom with mouse-scroll (or by pinch and zoom on a touch screen) and also rotate the image by shift-mouse scroll (by fingers on a touch screen). I presume you do not want to let the user disturb the image. To disable these features you need to use:
Code: Select all  Expand view

oImage:nUserControl := 0
 


If the image is smaller than the size of the control, the image is centered. If the image is larger than the control size, the image is reduced to fit the size of the control. If you wan the image to fit whether the image is smaller or larger please use
Code: Select all  Expand view

oImage:FitRect()
 


So, retain the existing behavior of your application, every time XImage is defined, please use this code:
Code: Select all  Expand view

oImage:nUserControl := 0
oImage:FitRect()
 


Note: XImage always retains the proportions when zoomed or unzoomed.

With XImage, you can use jpg, png, ico, tiff, emf files without freeimage.dll.
You can remove freeimage.dll, if you are using now.

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Wed Jun 12, 2019 6:16 am
by AngelSalom
Thanks Mr. Rao, now it works perfectly.
It's a really impressive job, thank you.

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Fri Jun 14, 2019 1:49 am
by nageswaragunupudi
Please see this post to see the copy/paste capabilities of ximage.

viewtopic.php?f=3&t=36313&p=222736&hilit=if+you+want+the+user#p222736

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Fri Jun 14, 2019 6:23 am
by AngelSalom
Very useful, thanks

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Sat Aug 31, 2019 8:59 pm
by augustogomes
Hello people

Do you know how to use ximage with Pelles C? What feature would you use?
I tried with the bitmap feature and it gets static, doesn't work ximage features

thankful
Augusto

Olá Pessoal

Vocês sabem como usar o ximage com Pelles C ? Qual recurso usaria?
Tentei com o recurso bitmap e ele fica statico, não funciona os recurso da ximage

Grato
Augusto

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Sun Sep 01, 2019 5:43 pm
by AngelSalom

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Wed Jan 08, 2020 1:44 pm
by concentra
nageswaragunupudi wrote:If the image is smaller than the size of the control, the image is centered. If the image is larger than the control size, the image is reduced to fit the size of the control. If you wan the image to fit whether the image is smaller or larger please use
Code: Select all  Expand view

oImage:FitRect()
 


Hi.
Is there an easy way to auto fit a TImage ( not a TXImage )?

[[]] Maurício Faria

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Wed Jan 08, 2020 1:57 pm
by AngelSalom

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Wed Jan 08, 2020 5:15 pm
by concentra


Gracias Angel !

Según su ejemplo, escribí un método para la clase TImage:
Code: Select all  Expand view

method FitRect() CLASS TImage

   local nW_Bmp := nBmpWidth( ::hBitmap )
   local nH_Bmp := nBmpHeight( ::hBitmap )
   local aRect  := GetClientRect( ::hWnd )
   local nW_Wnd := aRect[4] - aRect[2]
   local nH_Wnd := aRect[3] - aRect[1]
   local nZoom

   nZoom := ( nW_Wnd / nW_Bmp )
   if ( nH_Wnd / nH_Bmp ) < nZoom
      nZoom := ( nH_Wnd / nH_Bmp )
   endif

   ::Zoom( nZoom )
   ::Refresh()
   ::ScrollAdjust()

return nil

 


[[]] Maurício Faria

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Thu Jan 09, 2020 8:31 am
by AngelSalom
Excelente!

Re: Consulta acerca de TBitmap/Timage/Ximage

PostPosted: Thu Jan 09, 2020 1:09 pm
by karinha
Excelente!