Page 1 of 1

Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 3:16 pm
by quique
Hola a todos, tengo esta linea que lee un archivo tiff con 5 imágenes:

@2,2 IMAGE oImageInicia OF oWnd FILE "d:\quiquesoft\SiCredit\Captura2\Imagenes3\111485901.tiff" SCROLL

¿Es posible seleccionar que imágen es la que quierno mostrar?

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 4:36 pm
by karinha
Mira se ayuda:

Code: Select all  Expand view

#include 'fivewin.ch'

#define OFN_PATHMUSTEXIST            0x00000800
#define OFN_NOCHANGEDIR              0x00000008
#define OFN_ALLOWMULTISELECT         0x00000200
#define OFN_EXPLORER                 0x00080000     // new look commdlg
#define OFN_LONGNAMES                0x00200000     // force long names for 3.x modules
#define OFN_ENABLESIZING             0x00800000
#define OFN_HIDEREADONLY             0x00000004     // Oculta a caixa de seleção Somente leitura.
#define OFN_NONETWORKBUTTON          0x20000        // Desabilita o botão [ REDE ] da Dlg

function aGetFiles( cMask, cTitle, nDefaultMask, cInitDir )

   local cSelect, nAt, aFiles := {}
   /*
   local nFlags   := nOr( OFN_PATHMUSTEXIST , OFN_NOCHANGEDIR , ;
                     OFN_ALLOWMULTISELECT , OFN_EXPLORER , ;
                     OFN_LONGNAMES, OFN_ALLOWMULTISELECT )
   */

   local nFlags   := nOr( OFN_PATHMUSTEXIST, OFN_NOCHANGEDIR, OFN_ALLOWMULTISELECT, ;
                          OFN_LONGNAMES, OFN_NONETWORKBUTTON )

   SKINBUTTONS()

   //cSelect  := cGetFile( cMask, cTitle, nDefaultMask, cInitDir, .f., .t., nFlags )
   cSelect := cGetFile( "Bitmap (*.bmp)| *.bmp|"+      ;
                        "DIB   (*.dib)| *.dib|" +      ;
                        "PCX   (*.pcx)| *.pcx|" +      ;
                        "JPEG  (*.jpg)| *.jpg|" +      ;
                        "GIF   (*.gif)| *.gif|" +      ;
                        "TARGA (*.tga)| *.tga|" +      ;
                        "RLE   (*.rle)| *.rle|" +      ;
                        "Todos os Arquivos (*.*)|*.*|" ;
                        ,"Selecione a Foto Desejada",1,,.F.,, nFlags )

   cSelect  := Left( cSelect, At( Chr( 0 ) + Chr( 0 ), cSelect ) - 1 )

   if ! Empty( cSelect )
      cSelect  := StrTran( cSelect, Chr( 0 ), "," )
      aFiles  := hb_aTokens( cSelect, "," )
      if Len( aFiles ) > 1
         for nAt := 2 TO Len( aFiles )
            aFiles[ nAt ] := aFiles[ 1 ] + "\" + aFiles[ nAt ]
         next nAt
         ADel( aFiles, 1 )
         ASize( aFiles, Len( aFiles ) - 1 )
      endif
   endif

return aFiles



Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 4:45 pm
by quique
Gracias Karinha, pero cgetfile() me ayuda a seleccionar un archivo, lo que necesito es poder seleccionar la imágen dentro del archivo que ya tengo seleccionado, en el ejemplo que puse el archivo tiff tiene 5 imágenes, y lo que necesito es poder seleccionar la segunda o tercera.

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 4:51 pm
by karinha

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 5:21 pm
by quique
Gracias de nuevo Karinha, pero no solucionan el problema de seleccionar la imágen dentro del tiff

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 6:48 pm
by karinha
Muestra un ejemplo autocontenido porfa. salu2.

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 6:59 pm
by quique
Code: Select all  Expand view

  DEFINE WINDOW oWnd FROM 0, 0 TO 24, 80  

  @2,2 IMAGE oImageInicia OF oWnd FILE "111485901.tiff" SCROLL

  ACTIVATE WINDOW oWnd MAXIMIZED
 


Lo que hace falta es poder decirle que en lugar de mostrar la primera imágen, muestre la segunda

Re: Selecciona imagen de un TIFF

PostPosted: Mon Oct 19, 2015 8:12 pm
by mastintin
quique wrote:
Code: Select all  Expand view

  DEFINE WINDOW oWnd FROM 0, 0 TO 24, 80  

  @2,2 IMAGE oImageInicia OF oWnd FILE "111485901.tiff" SCROLL

  ACTIVATE WINDOW oWnd MAXIMIZED
 


Lo que hace falta es poder decirle que en lugar de mostrar la primera imágen, muestre la segunda


¿ Que version de fwh usas ? . Lo pregunto por la posibilidad de usar gdi+ para resolver el problema .
Code: Select all  Expand view

HB_FUNC( GDIPLUSIMGGETFRAME )
{
    Bitmap * gifImage = ( Bitmap * ) hb_parnl( 1 )
  int index = hb_parni(2) ;
 
  UINT nFrame = gifImage->GetFrameDimensionsCount();
  GUID* pDimensionIDs = (GUID*)malloc(sizeof(GUID)*nFrame);
  gifImage->GetFrameDimensionsList(pDimensionIDs, nFrame);
  gifImage->SelectActiveFrame( &pDimensionIDs[0] , index );  
 
 int nWidth  =  gifImage->GetWidth() ;
 int nHeight =  gifImage->GetHeight() ;
 
  Bitmap * frameImage = new Bitmap( nWidth, nHeight  );
  Graphics * gr = new Graphics( frameImage );

  gr->DrawImage(gifImage, 0, 0, nWidth, nHeight);
  delete gr ;
 
  hb_retnl( ( HB_LONG ) frameImage );
 
  }

 


Este código no está testado pero debería funcionar ...
partiendo de un hBitmap de gdi+ , y un numero de imagen ( empieza en cero ) devuelve un hbitmap gdi+ de la imagen del frame .
seria algo así :

Code: Select all  Expand view

local hbitmap
local obmp := tgdiplus():new( "archivo.tif")
local hFrame:=  GDIPLUSIMGGETFRAME(obmp:hbmp, 2)
       GDIPLUSIMAGEDISPOSE(obmp:hbmp)
        hbitmap:= GDIP_GETHBITMAP( hFrame )
        .......... usar la imagen ......
       
       GDIPLUSIMAGEDISPOSE( hFrame )
 

Re: Selecciona imagen de un TIFF

PostPosted: Tue Oct 20, 2015 12:26 am
by quique
mastintin gracias, no supe como compilarlo.

Tengo FW 12.04 lo que hice fue incluir el código C copiando la ídea de otro fuente de los que incluye FW.

Code: Select all  Expand view

#pragma BEGINDUMP
#include <windows.h>
#include <winuser.h>
#include <wingdi.h>
#include "hbapi.h"
HB_FUNC( GDIPLUSIMGGETFRAME )
{
    Bitmap * gifImage = ( Bitmap * ) hb_parnl( 1 );
.
.
.
.
  hb_retnl( ( HB_LONG ) frameImage );

  }
#pragma ENDDUMP
 


pero me marca varios errores comenzando con estos:

Error E2451 D:\\quiquesoft\\SiCredit\\Digital3\\prg\\Digital.prg 1716: Undefined symbol 'Bitmap' in function HB_FUN_GDIPLUSIMGGETFRAME
Error E2451 D:\\quiquesoft\\SiCredit\\Digital3\\prg\\Digital.prg 1716: Undefined symbol 'GIFiMAGE' in function HB_FUN_GDIPLUSIMGGETFRAME

La línea 1716 es

Bitmap * gifImage = ( Bitmap * ) hb_parnl( 1 );

o sea, la primera línea de la función

(esto es al compilar C, porque todavía falta ver que le atine a la insercción del código FW)

Re: Selecciona imagen de un TIFF

PostPosted: Tue Oct 20, 2015 5:53 am
by mastintin
Te falla porque es código C++ y no C y porque tienes que incluir la librería gdi+ al archivo de compilación. De todas formas con esa versión de fwh no podrás hacerlo pues te faltan el resto de las funciones fwh para gdi+ , las que inicializan el sistema gdi+ , carga ficheros de imagen , los libera , etc .
Lo siento :-(

Re: Selecciona imagen de un TIFF

PostPosted: Tue Oct 20, 2015 3:18 pm
by quique
Mastintin, gracias por la respuesta