FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour problema llamando png desde recursos
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
problema llamando png desde recursos
Posted: 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 (fw): Select all Collapse
  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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: problema llamando png desde recursos
Posted: Mon Apr 29, 2013 07: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
Posts: 1074
Joined: Fri Oct 07, 2005 01:56 PM
Re: problema llamando png desde recursos
Posted: Mon Apr 29, 2013 08: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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: problema llamando png desde recursos
Posted: Tue Apr 30, 2013 08: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: problema llamando png desde recursos
Posted: Tue Apr 30, 2013 08:57 AM
Este es el c贸digo de la funci贸n:

Code (fw): Select all Collapse
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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: problema llamando png desde recursos
Posted: Thu May 02, 2013 04:15 PM
A帽adida la function al final de tbitmap.prg lanza los errores de abajo .... me faltan cosas para que compile.

Code (fw): Select all Collapse
#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

Continue the discussion