EN el archivo gdiplus.cpp
- Code: Select all Expand view
HB_FUNC( GDIPLUSISEMPTYGRAPHICS)
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
hb_retl( ( BOOL ) graphics->IsClipEmpty() ) ;
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSSETSMOOTHINGGRAPHICS )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
int nType = hb_parni( 2 );
switch (nType){
case 1:
graphics->SetSmoothingMode( SmoothingModeNone ) ;
case 2:
graphics->SetSmoothingMode( SmoothingModeDefault );
case 3:
graphics->SetSmoothingMode( SmoothingModeHighSpeed );
case 4:
graphics->SetSmoothingMode( SmoothingModeHighQuality );
case 5:
graphics->SetSmoothingMode( SmoothingModeAntiAlias );
}
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSIMAGECREATETHUMB )
{
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
int nWidth = hb_parni( 2 );
int nHeight = hb_parni( 3 );
Image * hThumb = newImage->GetThumbnailImage( nWidth , nHeight, NULL, NULL );
hb_retnl( ( HB_LONG ) hThumb );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSCREATEHBITMAPIMAGE )
{
HBITMAP handle;
int error;
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
error = newImage->GetHBITMAP( Color( 0,0,0 ), &handle );
if ( error != 0 )
{
hb_retnl( ( HB_LONG ) NULL );
}
hb_retnl( ( HB_LONG ) handle );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSGETWIDTHBITMAP)
{
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
hb_retnl( ( HB_LONG ) newImage->GetWidth() );
}
HB_FUNC( GDIPLUSGETHEIGHTBITMAP)
{
Bitmap * newImage = ( Bitmap * ) hb_parnl( 1 );
hb_retnl( ( HB_LONG ) newImage->GetHeight());
}
Aparte tengo este código que no consigo que funcione ....Me devuelve un numero de hbitmap pero no pinta nada ...
- Code: Select all Expand view
HB_FUNC( GDIPLUSCREATEBITMAPFROMSTREAM )
{
IStream *pStream = NULL;
HGLOBAL m_hBuffer = GlobalAlloc(GMEM_MOVEABLE, 0);
// HGLOBAL m_hBuffer = GlobalAlloc(GMEM_FIXED, IMAGE_SIZE);
if (CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream ) != S_OK )
{
GlobalFree( m_hBuffer );
hb_retl ( (bool) FALSE );
}
size_t size = GlobalSize(m_hBuffer);
FILE *f;
f = fopen("app.bmp", "rb");
if( f == NULL)
MessageBox( GetActiveWindow(), "fallo", "No carga la imagen", 0x30 );
fread( m_hBuffer,1,size,f);
fclose(f);
GlobalFree( m_hBuffer );
// create Bitmap
Bitmap* bitmap = new Bitmap( pStream );
// Bitmap* bitmap = new Bitmap( L"app.bmp" );
hb_retnl( ( HB_LONG ) bitmap );
}
Aqui el codigo tGdiplus y una función para crear thumbnails ....
- Code: Select all Expand view
METHOD CreateHbitmap( ) INLINE GdiPlusCreateHBitmapImage( ::hBmp ) //devuelve un hbitmap GDI normal
METHOD getWidth() INLINE GdiPlusGetWidthBitmap( ::hbmp )
METHOD getHeight() INLINE GdiPlusGetHeightBitmap( ::hbmp )
METHOD CreateThumbnail( nWidth, nHeight ) CLASS GDIBmp
local oThumb:= gdiBmp():new()
local hImage
local nRatio
if Empty( nHeight )
nRatio := ::getWidth()/::getHeight()
nHeight := nWidth * nRatio
endif
hImage := GdiPlusImageCreateThumb( ::hbmp, nWidth, nHeight )
oThumb:hBmp := hImage
Return oThumb
//----------------------------------------------------------------------------//
Function GDIPlusSaveThumbnail( cImageIni, cImageEnd , nWhidth, nHeight )
local cExtIni := Upper(cFileExt( cImageIni ))
local oImage:= GDIBmp():New( cImageIni )
local oThumb
local nScan
if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0
Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
return .f.
endif
oThumb:= oImage:CreateThumbmail( nWhidth, nHeight )
oThumb:Save( cImageEnd )
oImage:Destroy()
oThumb:Destroy()
return .t.
Por ahora es lo que tengo nuevo .
Un Ejemplo del paso desde gdi+ a gdi normal :
- Code: Select all Expand view
function Main()
local oWnd
local oImage
DEFINE WINDOW oWnd TITLE "Testing GDI+ Class" FROM 5,5 TO 600, 800 PIXEL
@ 3, 38 BITMAP oimage File "hola" size 120,120 of oWnd // cargamos la imagen en vacio.
ACTIVATE WINDOW oWnd ;
ON PAINT Gditest( oImage )
return nil
function Gditest( oImage )
local cfile:= cGetfile("escoge una imagen") // funciona también con png
// local cFile := "c:\fwh\bitmaps\pngs\image6.png"
local obmp:= gdiBmp():new( cFile )
oImage:hBitmap := obmp:CreateHbitmap( )
oImage:HasAlpha()
oimage:refresh()
Return nil