problema llamando png desde recursos

problema llamando png desde recursos

Postby mastintin » Mon Apr 29, 2013 11:05 am

Estoy colocando este código para poder llamar desde recursos los png ( en la clase bitmap ) , pero ::hBitmap = FWPngFromMemory(a_resHandle) de devuelve 0

creo que estoy pasando el puntero del array en vez el array ¿ como funcionaría ?


Code: Select all  Expand view

  IF ( hRes:= FindResource( GetResources(), cResName , RT_RCDATA ) ) != 0
          IF ( a_resHandle := LoadResource( GetResources(),  hRes ) ) != 0
            pausa(1)
            ::hBitmap  = FWPngFromMemory(a_resHandle)
             pausa( ::hBitmap )
             pausa("png")

           ::hPalette = 0
           lChanged  := .t.
           cBmpFile  := nil


         endif
 endif
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: problema llamando png desde recursos

Postby Antonio Linares » Mon Apr 29, 2013 7:52 pm

Manuel,

LoadResource() devuelve un handle ( HGLOBAL ) que FWH devuelve como un número.

Asi que tu función lo que recibe es un número y no un array. Solo tienes que modificar la función FWPngFromMemory() para que reciba un número ( hb_parnl() )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problema llamando png desde recursos

Postby Patricio Avalos Aguirre » Mon Apr 29, 2013 8:16 pm

Antono


November 2011
=============
+ new function FWPngFromMemory( <Bytes> ) Open a png File from array bytes <Bytes> return a bitmap handle


FWPngFromMemory no viene el fuente, esta en la libreria FIVEHC.LIB
Saludos
Patricio

__________________________________________________________________
Version: Harbour 3.2.0dev (r1307082134),Compiler: Borland C++ 5.8.2 (32-bit)
PCode version: 0.3, FWH 13.2
http://www.sialm.cl
User avatar
Patricio Avalos Aguirre
 
Posts: 1060
Joined: Fri Oct 07, 2005 1:56 pm
Location: La Serena, Chile

Re: problema llamando png desde recursos

Postby mastintin » Tue Apr 30, 2013 8:09 am

De momento lo he resuelto asi :

viewtopic.php?f=6&t=26183#p143801

Tiene razón Patricio , no disponemos de FWPngFromMemory() para cambiarla porlo que sería bueno tener una funcion que rescatase los png desde recursos directamente .

Patricio Avalos Aguirre wrote:Antono


November 2011
=============
+ new function FWPngFromMemory( <Bytes> ) Open a png File from array bytes <Bytes> return a bitmap handle


FWPngFromMemory no viene el fuente, esta en la libreria FIVEHC.LIB
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: problema llamando png desde recursos

Postby Antonio Linares » Tue Apr 30, 2013 8:57 am

Este es el código de la función:

Code: Select all  Expand view
HB_FUNC( FWPNGFROMMEMORY )
{

   PFWPNG pPng = ( PFWPNG ) hb_xgrab( sizeof( FWPNG ) );
   HB_FHANDLE Info = ( HB_FHANDLE ) hb_parc( 1 );
   
   ReadFromMemory( pPng, Info );
   
   hb_retnl( ( LONG ) pPng->hBitmap );
   hb_xfree( pPng->image_data );
   hb_xfree( pPng->row_pointers );
   hb_xfree( pPng );
   
}


Creo que este código lo desarrolló Daniel, y actualmente está de viaje. Yo creo que tiene un error, y que debiera ser hb_parnl( 1 ) en vez de hb_parc( 1 ), por si te animas a probarlo. O tal vez, hb_parptr( 1 )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41449
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problema llamando png desde recursos

Postby mastintin » Thu May 02, 2013 4:15 pm

Añadida la function al final de tbitmap.prg lanza los errores de abajo .... me faltan cosas para que compile.

Code: Select all  Expand view



#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <hbdefs.h>

HB_FUNC( FWPNGFROMMEMORY )
{

   PFWPNG pPng = ( PFWPNG ) hb_xgrab( sizeof( FWPNG ) );
   HB_FHANDLE Info = ( HB_FHANDLE ) hb_parc( 1 );

   ReadFromMemory( pPng, Info );
   
   hb_retnl( ( LONG ) pPng->hBitmap );
   hb_xfree( pPng->image_data );
   hb_xfree( pPng->row_pointers );
   hb_xfree( pPng );
   
}

 #pragma ENDDUMP

 



Obj\bitmap.c:
Error E2451 bitmap.prg 1112: Undefined symbol 'PFWPNG' in function HB_FUN_FWPNGFROMMEMORY
Error E2379 bitmap.prg 1112: Statement missing ; in function HB_FUN_FWPNGFROMMEMORY
Error E2140 bitmap.prg 1113: Declaration is not allowed here in function HB_FUN_FWPNGFROMMEMORY
Error E2451 bitmap.prg 1115: Undefined symbol 'pPng' in function HB_FUN_FWPNGFROMMEMORY
Warning W8065 bitmap.prg 1115: Call to function 'ReadFromMemory' with no prototype in function HB_FUN_FWPNGFROMMEMORY
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 106 guests