Drawing on a TImage and save [Solved]

Re: Drawing on a TImage and save [Solved]

Postby csincuir » Tue Apr 01, 2014 11:04 am

Uwe,
How do you do to draw lines or free hand, over the image?
Dou you have some examples?

Best regards.

Carlos.
csincuir
 
Posts: 408
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: Drawing on a TImage and save [Solved]

Postby ukoenig » Tue Apr 01, 2014 12:25 pm

Carlos,

as soon it will be finished, I will add a DOWNLOAD-link
of the COMPLETE sample.

Best regards
Uwe :lol:
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: Drawing on a TImage and save [Solved]

Postby cnavarro » Tue Apr 01, 2014 2:10 pm

https://www.dropbox.com/s/fy1jpxrqc4kkiop/TImage.png

Cómo hacer que el tamaño del control se adapte al tamaño de la imagen a mostrar
Conozco la claúsula ADJUST, adapta la imagen al tamaño del control
Tampoco me funciona la claúsula SIZE
Cualquier imagen presentada es situada en un control el doble de tamaño de la imagen
El tamaño de la imagen EAGLE.JPG es 150x100 y el control lo construye de tamaño 300x200

How do you control the size fits the image size to show
I know the ADJUST clause, the image adapts to the size of the control
Nor do I work the SIZE clause
Any displayed image is located in a control double image size
The image size is 150x100 eagle.jpg control is constructed and sized 300x200

Code: Select all  Expand view  RUN

@ 15, 5 IMAGE oImg PIXEL FILE "EAGLE.JPG" OF oDlg //ADJUST
 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Drawing on a TImage and save [Solved]

Postby Enrico Maria Giordano » Tue Apr 01, 2014 2:59 pm

Cristobal,

cnavarro wrote:Cómo hacer que el tamaño del control se adapte al tamaño de la imagen a mostrar


You can use something like:

Code: Select all  Expand view  RUN
oImg:SetSize( oImg:nWidth(), oImg:nHeight() )


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a TImage and save [Solved]

Postby cnavarro » Tue Apr 01, 2014 3:24 pm

Enrico, perfecto
Por que no se incluye en la class TImage directamente?

Enrico perfect
What is not included in the TImage class directly?

Enrico [write]

Thank you. Unfortunately, the image is out of alignment (ie. is slightly shifted)


Enrico, entre tu ejemplo y el mio hay una diferencia de 4 pixels de tamaño en el ancho y 4 pixeles de tamaño en el alto (más pequeño el mio): ¿puede ser el borde del control?
En la imagen, ahora, me aparece un fino borde blanco.

Enrico between your example and mine is a difference of 4 pixels in size in width and 4 pixel size on High (smaller mine): can be the edge of control?
In the picture, now, me a thin white border appears
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Drawing on a TImage and save [Solved]

Postby Enrico Maria Giordano » Tue Apr 01, 2014 5:22 pm

Cristobal,

can you show me a little sample of the problem?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a TImage and save [Solved]

Postby cnavarro » Tue Apr 01, 2014 5:46 pm

Enrico,
pasa lo mismo con tu ejemplo inicial
Si observas, el control tiene un tamaño mayor que la imagen ( fichero .jpg )
En tu ejemplo el fondo del dialog es blanco y no se ve bien el tamaño del control

https://www.dropbox.com/s/fy1jpxrqc4kkiop/TImage.png

so with your initial example
If you look, the control is larger than the image (file. Jpg)
In your example the bottom of the dialog is white and does not look good size control

https://www.dropbox.com/s/itbqmyk75lha9pa/Eagle.jpg

Code: Select all  Expand view  RUN

FUNCTION MAIN()

    Local oDlg
    Local oImg
    Local nOpt
    Local oFont
   
    DEFINE FONT oFont NAME "Segoe UI Light" SIZE 0, -12

    DEFINE DIALOG oDlg SIZE 610, 410 ;
    COLOR CLR_WHITE, RGB(  51, 51, 51 )// ;

                      //SIZE 150, 100 PIXEL  
    @ 15, 5 IMAGE oImg PIXEL FILE "EAGLE.JPG" OF oDlg //ADJUST

    @ 168, 5 FLATBTN PROMPT "Draw " SIZE 40, 20 ;
    COLOR RGB(  51, 51, 51 ), CLR_WHITE ;
    FONT oFont //ACTION ( DrawImg( oImg ) )
           
    @ 168, 55 FLATBTN PROMPT "Save FW" SIZE 40, 20 ;
    COLOR RGB(  51, 51, 51 ), CLR_WHITE ;    
    FONT oFont //ACTION oImg:SaveImage( "IMGENFW.JPG", 2 )

    @ 168, 105 FLATBTN PROMPT "Save C" SIZE 40, 20 ;
    COLOR RGB(  51, 51, 51 ), CLR_WHITE ;
    FONT oFont //ACTION ( nOpt := CaptureImage( oImg:hWnd, "IMAGENC.BMP" ) )

    @ 168, 155 FLATBTN PROMPT "Exit" SIZE 40, 20;
    COLOR RGB(  51, 51, 51 ), CLR_WHITE ;    
    FONT oFont ACTION oDlg:End()

    ACTIVATE DIALOG oDlg CENTER //;
     //ON INIT ( oImg:SetSize( oImg:nWidth(), oImg:nHeight() ) )

    //oFont:End()
   
    RETURN NIL
 
Last edited by cnavarro on Tue Apr 01, 2014 7:19 pm, edited 1 time in total.
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Drawing on a TImage and save [Solved]

Postby Enrico Maria Giordano » Tue Apr 01, 2014 6:08 pm

Cristobal,

your sample is not compilable. Please fix it and resend.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a TImage and save [Solved]

Postby cnavarro » Tue Apr 01, 2014 7:21 pm

He modificado el anterior

I modified the previous

O puedes compilar este

Or you can compile this

Code: Select all  Expand view  RUN


#include "Fivewin.ch"

FUNCTION MAIN()

    Local oDlg
    Local oImg
    Local nOpt
    Local oFont
   
    //DEFINE FONT oFont NAME "Lucida Console" SIZE 0, -12

    DEFINE DIALOG oDlg SIZE 610, 410 ;
    COLOR CLR_WHITE, RGB(  51, 51, 51 )// ;

                      //SIZE 150, 100 PIXEL  
    @ 15, 5 IMAGE oImg PIXEL FILE "EAGLE.JPG" OF oDlg //ADJUST

  @ 168, 5 BUTTON "Draw " SIZE 40, 20 PIXEL
           
  @ 168, 55 BUTTON "Save Fw" SIZE 40, 20 PIXEL

  @ 168, 105 BUTTON "Save C " SIZE 40, 20 PIXEL

  @ 168, 155 BUTTON "Exit" SIZE 40, 20 PIXEL ACTION oDlg:End()

    ACTIVATE DIALOG oDlg CENTER //;
     //ON INIT ( oImg:SetSize( oImg:nWidth(), oImg:nHeight() ) )

    //oFont:End()
   
    RETURN NIL

 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Drawing on a TImage and save [Solved]

Postby Enrico Maria Giordano » Tue Apr 01, 2014 8:27 pm

Cristobal,

now I can compile the sample but, sorry, I don't understand what is the problem you are referring to. Can you explain, please?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a TImage and save [Solved]

Postby cnavarro » Tue Apr 01, 2014 8:47 pm

Look

Original Image Size: 150 x 100
Tamaño original de la imagen: 150 x 100

https://www.dropbox.com/s/fy1jpxrqc4kkiop/TImage.png

When you create the control has twice the size of the image containing
I have to do the oImg: SetSize you've told me
Why the size of the control is not adjusted to the size of the image?

Cuando creas el control tiene el doble de tamaño que la imagen que contiene
Tengo que hacer el oImg:SetSize que me has explicado
Por qué no se ajusta el tamaño del control al tamaño de la imagen?
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Drawing on a TImage and save [Solved]

Postby ukoenig » Tue Apr 01, 2014 8:54 pm

Cristobal,

saves to a BMP with paintings works :
ACTION oImg:SaveToBmp( cDestFile )

doesn't work painting is not included !!!
ACTION oImg:SaveImage( cDestFile, 2, 25 )

Because of image-resizing, first I save the original image-size.

STATIC FUNCTION GET_IMGSIZE(cWorkfile)
LOCAL oTest

DEFINE IMAGE oTest FILENAME c_path1 + cWorkFile
nImgWidth := oTest:nWidth
nImgHeight := oTest:nHeight
oTest:End()

RETURN NIL


After selecting a resize-factor ( 50 - 130 % ), I use

oDrawImg:Move( 1, 1, nImgWidth * (nResize / 100), nImgHeight * (nResize / 100), .f. )

To display the image, I use :

@ 1, 1 IMAGE oDrawImg FILENAME NIL OF oSDlg ;
SIZE 100, 100 PIXEL BORDER // size will be calculated
oDrawImg:cTooltip := "selected Image"
oDrawImg:bPainted := { |hDC| DRAW_IMAGE( oDrawImg, hDC, cWorkFile ), ;
IIF( nLineStyle = 2, Click( hDC, x, y ), NIL ) } // Freehand painting


I resorted the surface and added a dialog-painter

Image


Best regards
Uwe :?:
Last edited by ukoenig on Wed Apr 02, 2014 11:59 am, edited 4 times 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: Drawing on a TImage and save [Solved]

Postby Enrico Maria Giordano » Tue Apr 01, 2014 9:20 pm

Cristobal,

cnavarro wrote:Look

Original Image Size: 150 x 100
Tamaño original de la imagen: 150 x 100

https://www.dropbox.com/s/fy1jpxrqc4kkiop/TImage.png

When you create the control has twice the size of the image containing
I have to do the oImg: SetSize you've told me
Why the size of the control is not adjusted to the size of the image?

Cuando creas el control tiene el doble de tamaño que la imagen que contiene
Tengo que hacer el oImg:SetSize que me has explicado
Por qué no se ajusta el tamaño del control al tamaño de la imagen?


Because it's not intended to work such way. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Drawing on a TImage and save [Solved]

Postby csincuir » Tue Apr 01, 2014 11:50 pm

Carlos,

as soon it will be finished, I will add a DOWNLOAD-link
of the COMPLETE sample.

Thank you Uwe.

Best regards.

Carlos.
csincuir
 
Posts: 408
Joined: Sat Feb 03, 2007 6:36 am
Location: Guatemala

Re: Drawing on a TImage and save [Solved]

Postby cnavarro » Wed Apr 02, 2014 10:12 am

Thanks Uwe

saves to a BMP with paintings works :
ACTION oImg:SaveToBmp( cDestFile )

doesn't work painting is not included !!!
ACTION oImg:SaveImage( cDestFile, 2, 25 )

Mi problema no es con el tamaño de la imagen
El problema es con el tamaño del control TImage que contiene la imagen
Disculpa, si no te he entendido bien. Mi ingles es muy pobre

My problem is not with the size of the image
The problem is with the size of the TImage control that contains the image
Sorry if I misunderstood you well. My English is very poor


Enrico

Enrico Maria Giordano wrote:Cristobal,

Because it's not intended to work such way. :-)

EMG



Esta modificacion hace lo que necesito
Pero, la modificacion tendria que hacerla en la clase TBitmap
Aunque la imagen que obtengo en C es mas pequeña. Voy a comprobar si la diferencia es por la claúsula NOBORDER

This modification does what I need
But the amendment would have to do it in the TBitmap class
Although the image I get in C is smaller. I'll check if the difference is by the clause NOBORDER

https://www.dropbox.com/s/ofepd54kv80q95z/IMAGENC.BMP

https://www.dropbox.com/s/co96szxghn5ia1u/IMGENFW.JPG

https://www.dropbox.com/s/fy1jpxrqc4kkiop/TImage.png

https://www.dropbox.com/s/srgojq5ordz0ljp/Timage1.png

Code: Select all  Expand view  RUN

//-----------------------------------------------------------------------------
#include "Constant.ch"
//----------------------------------------------------------------------------//
#xcommand @ <nRow>, <nCol> IMAGEC [ <oImg> ] ;
             [ <resource: NAME, RESNAME, RESOURCE> <cResName> ] ;
             [ <file: FILENAME, FILE, DISK> <cBmpFile> ] ;
             [ <NoBorder:NOBORDER, NO BORDER> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <of: OF, WINDOW, DIALOG> <oWnd> ] ;
             [ <lClick: ON CLICK, ON LEFT CLICK> <uLClick> ] ;
             [ <rClick: ON RIGHT CLICK> <uRClick> ] ;
             [ <scroll: SCROLL> ] ;
             [ <adjust: ADJUST> ] ;
             [ CURSOR <oCursor> ] ;
             [ <pixel: PIXEL>   ] ;
             [ MESSAGE <cMsg>   ] ;
             [ <update: UPDATE> ] ;
             [ WHEN <uWhen> ] ;
             [ VALID <uValid> ] ;
             [ <lDesign: DESIGN> ] ;
       => ;
          [ <oImg> := ] TCImage():New( <nRow>, <nCol>, <nWidth>, <nHeight>,;
             <cResName>, <cBmpFile>, <.NoBorder.>, <oWnd>,;
             [\{ |nRow,nCol,nKeyFlags| <uLClick> \} ],;
             [\{ |nRow,nCol,nKeyFlags| <uRClick> \} ], <.scroll.>,;
             <.adjust.>, <oCursor>, <cMsg>, <.update.>,;
             <{uWhen}>, <.pixel.>, <{uValid}>, <.lDesign.>, [<(oImg)>] )

CLASS TCImage FROM TImage

METHOD New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder,;
            oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
            cMsg, lUpdate, bWhen, lPixel, bValid, lDesign, cVarName ) CONSTRUCTOR

ENDCLASS

METHOD New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder,;
            oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,;
            cMsg, lUpdate, bWhen, lPixel, bValid, lDesign, cVarName ) CLASS TCImage

  ::Super:New( nTop, nLeft, nWidth, nHeight, cResName, cBmpFile, lNoBorder, ;
              oWnd, bLClicked, bRClicked, lScroll, lStretch, oCursor,      ;
              cMsg, lUpdate, bWhen, lPixel, bValid, lDesign, cVarName )
 
  if ! Empty( cResName ) .or. ! Empty( cBmpFile )
      DEFAULT nWidth  := Min( ::nWidth(), oWnd:nWidth() ),;
              nHeight := Min( ::nHeight(), oWnd:nHeight() )
  else
      DEFAULT nWidth  := 100, nHeight := 100
  endif
 
  ::nTop     := If( lPixel, nTop, nTop * BMP_CHARPIX_H )   // 14
  ::nLeft    := If( lPixel, nLeft, nLeft * BMP_CHARPIX_W)  // 8
   
  if Upper( oWnd:ClassName() ) <> "TWINDOW"
  ::nBottom  := ::nTop + Int(nHeight/2) - 1                       // Aqui
  ::nRight   := ::nLeft + Int(nWidth/2) - 1                         // Aqui
  endif
 
return Self

 
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: 6549
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 72 guests