documentacion de funciones gdi+
documentacion de funciones gdi+
Revisando en la wiki las funciones gdi+ veo que no estan documentadas pero ademas sus nombres no corresponden con las funciones que aparecen en la clase tgdiplus. Por otro lado las funciones que estan en tgdiplus ¿ en que archivo se encuentran de la api ? . He revisado los libs y tampoco aparecen ¿? . Sería bueno completar un poco mas la clase tgdiplus ...
Saludos.
Saludos.
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Manuel,
gdiplus.cpp (ojo que es C++)
gdiplus.cpp (ojo que es C++)
Code: Select all | Expand
// GdiPlus support (c) FiveTech Software
#include <hbapi.h>
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSNEWGRAPHICS )
{
hb_retnl( ( HB_LONG ) new Graphics( ( HDC ) hb_parnl( 1 ) ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDELETEGRAPHICS )
{
delete ( ( Graphics * ) hb_parnl( 1 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSHIGHQUALITY )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
graphics->SetSmoothingMode( SmoothingModeHighQuality );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSNORMALQUALITY )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
graphics->SetSmoothingMode( SmoothingModeDefault );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSNEWPEN )
{
Color clr = Color( hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ) );
hb_retnl( ( HB_LONG ) new Pen( clr ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSPENSIZE )
{
Pen * pen = ( Pen * ) hb_parnl( 1 );
pen->SetWidth( hb_parnl( 2 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSPENSTYLE )
{
Pen * pen = ( Pen * ) hb_parnl( 1 );
pen->SetLineCap( ( LineCap ) hb_parnl( 2 ), ( LineCap ) hb_parnl( 2 ),
( DashCap ) hb_parnl( 2 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSALIGN )
{
Pen * pen = ( Pen * ) hb_parnl( 1 );
pen->SetAlignment(PenAlignmentInset);
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSNOALIGN )
{
Pen * pen = ( Pen * ) hb_parnl( 1 );
pen->SetAlignment(PenAlignmentCenter);
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDELETEPEN )
{
delete ( ( Pen * ) hb_parnl( 1 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSNEWSOLIDBRUSH )
{
Color clr = Color( hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ) );
hb_retnl( ( HB_LONG ) new SolidBrush( clr ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDELETEBRUSH )
{
delete ( ( Brush * ) hb_parnl( 1 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDRAWLINE )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
if HB_ISNUM( 2 ) // if pen-object
{
Pen * pen = ( Pen * ) hb_parnl( 2 );
graphics->DrawLine( pen, ( float ) hb_parnd( 3 ),
( float ) hb_parnd( 4 ), ( float ) hb_parnd( 5 ),
( float ) hb_parnd( 6 ) );
}
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDRAWRECT )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
Pen * pen = ( Pen * ) hb_parnl( 2 );
float nLeft = hb_parnd( 4 );
float nTop = hb_parnd( 5 );
float nWidth = hb_parnd( 6 );
float nHeight = hb_parnd( 7 );
if HB_ISNUM( 3 ) // if brush-object
{
Brush * brush = ( Brush * ) hb_parnl( 3 );
graphics->FillRectangle( brush, nLeft, nTop, nWidth, nHeight );
}
if HB_ISNUM( 2 ) //if pen-object
{
Pen * pen = ( Pen * ) hb_parnl( 2 );
graphics->DrawRectangle( pen, nLeft, nTop, nWidth, nHeight );
}
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDRAWELLIPSE )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
Pen * pen = ( Pen * ) hb_parnl( 2 );
float nLeft = hb_parnd( 4 );
float nTop = hb_parnd( 5 );
float nWidth = hb_parnd( 6 );
float nHeight = hb_parnd( 7 );
if HB_ISNUM( 3 ) //if brush-object
{
Brush * brush = ( Brush * ) hb_parnl( 3 );
graphics->FillEllipse( brush, nLeft, nTop, nWidth, nHeight );
}
if HB_ISNUM( 2 ) //if pen-object
{
Pen * pen = ( Pen * ) hb_parnl( 2 );
graphics->DrawEllipse( pen, nLeft, nTop, nWidth, nHeight );
}
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSSTARTUP )
{
hb_retl( GdiplusStartup( &gdiplusToken, &gdiplusStartupInput, NULL ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSSHUTDOWN )
{
GdiplusShutdown( gdiplusToken );
}
//----------------------------------------------------------------------------//
HB_FUNC( SETPAGEUNIT2PIXEL )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
graphics->SetPageUnit( UnitPixel ); // Unit to Pixel
}
//----------------------------------------------------------------------------//
Re: documentacion de funciones gdi+
Antonio . Mira en esta página las cosas que hacen en vb con gdi+
.
http://leandroascierto.com/blog/category/graficos/
La cosa viene del borderlight para los gets , lo he realizado en gdi+ ,con el sistema que proponias de rectangulos cambiando de color y queda fino . Faltaria crear los rectangulos "roundrec" y guardar el fondo en un hbmp para recuperarlo cunado pierde el foco .
Para los rectangulos con bordes redondeados necesitamos pintar curvas ( no lo tenemos aún ) y pintar el paths ( tampoco ) ....

http://leandroascierto.com/blog/category/graficos/
La cosa viene del borderlight para los gets , lo he realizado en gdi+ ,con el sistema que proponias de rectangulos cambiando de color y queda fino . Faltaria crear los rectangulos "roundrec" y guardar el fondo en un hbmp para recuperarlo cunado pierde el foco .
Para los rectangulos con bordes redondeados necesitamos pintar curvas ( no lo tenemos aún ) y pintar el paths ( tampoco ) ....
Re: documentacion de funciones gdi+
con :
c:\bcc582\bin\bcc32 -P -c -O2 -Ic:\harbour\include -Ic:\bcc582\include gdipluss.cpp
me da estos errores....
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdipluss.cpp:
Error E2209 c:\bcc582\include\gdiplus.h 21: Unable to open include file 'algorit
hm'
Error E2316 c:\bcc582\include\gdiplus.h 22: 'min' is not a member of 'std'
Error E2272 c:\bcc582\include\gdiplus.h 22: Identifier expected
Error E2316 c:\bcc582\include\gdiplus.h 23: 'max' is not a member of 'std'
Error E2272 c:\bcc582\include\gdiplus.h 23: Identifier expected
Error E2268 c:\bcc582\include\GdiplusTypes.h 459: Call to undefined function 'mi
n' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 461: Call to undefined function 'ma
x' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 483: Call to undefined function 'ma
x' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 484: Call to undefined function 'ma
x' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 485: Call to undefined function 'mi
n' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 486: Call to undefined function 'mi
n' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 647: Call to undefined function 'mi
n' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 648: Call to undefined function 'mi
n' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 649: Call to undefined function 'ma
x' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 650: Call to undefined function 'ma
x' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 671: Call to undefined function 'ma
x' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 672: Call to undefined function 'ma
x' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 673: Call to undefined function 'mi
n' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 674: Call to undefined function 'mi
n' in function Rect::Union(Rect &,const Rect &,const Rect &)
Warning W8004 gdipluss.cpp 150: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWRECT()
Warning W8004 gdipluss.cpp 174: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWELLIPSE()
*** 19 errors in Compile ***
c:\bcc582\bin\bcc32 -P -c -O2 -Ic:\harbour\include -Ic:\bcc582\include gdipluss.cpp
me da estos errores....
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdipluss.cpp:
Error E2209 c:\bcc582\include\gdiplus.h 21: Unable to open include file 'algorit
hm'
Error E2316 c:\bcc582\include\gdiplus.h 22: 'min' is not a member of 'std'
Error E2272 c:\bcc582\include\gdiplus.h 22: Identifier expected
Error E2316 c:\bcc582\include\gdiplus.h 23: 'max' is not a member of 'std'
Error E2272 c:\bcc582\include\gdiplus.h 23: Identifier expected
Error E2268 c:\bcc582\include\GdiplusTypes.h 459: Call to undefined function 'mi
n' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 461: Call to undefined function 'ma
x' in function RectF::Intersect(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 483: Call to undefined function 'ma
x' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 484: Call to undefined function 'ma
x' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 485: Call to undefined function 'mi
n' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 486: Call to undefined function 'mi
n' in function RectF::Union(RectF &,const RectF &,const RectF &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 647: Call to undefined function 'mi
n' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 648: Call to undefined function 'mi
n' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 649: Call to undefined function 'ma
x' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 650: Call to undefined function 'ma
x' in function Rect::Intersect(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 671: Call to undefined function 'ma
x' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 672: Call to undefined function 'ma
x' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 673: Call to undefined function 'mi
n' in function Rect::Union(Rect &,const Rect &,const Rect &)
Error E2268 c:\bcc582\include\GdiplusTypes.h 674: Call to undefined function 'mi
n' in function Rect::Union(Rect &,const Rect &,const Rect &)
Warning W8004 gdipluss.cpp 150: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWRECT()
Warning W8004 gdipluss.cpp 174: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWELLIPSE()
*** 19 errors in Compile ***
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Manuel,
Parece que no te localiza este fichero:
c:\bcc582\include\dinkumware\algorithm
Comprueba que lo tengas
Parece que no te localiza este fichero:
c:\bcc582\include\dinkumware\algorithm
Comprueba que lo tengas
Re: documentacion de funciones gdi+
le he forzado el path al include que faltaba ...
Compila con dos warnings...
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdipluss.cpp:
Warning W8004 gdipluss.cpp 150: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWRECT()
Warning W8004 gdipluss.cpp 174: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWELLIPSE()
Antonio , ¿ has mirado el enlace http://leandroascierto.com/blog/category/graficos/ ? .
Tiene un codigo para cargar una imagen en un formato ( “BMP, DIB, JPG, JPEG, JPE, JFIF, GIF, PNG, TIF, TIFF, EMF, WMF, ICO, CUR”. ) y pasarla a otro usando gdi+ que es buenisima .. http://leandroascierto.com/blog/modulo- ... -otro-gdi/
Compila con dos warnings...
Borland C++ 5.82 for Win32 Copyright (c) 1993, 2005 Borland
gdipluss.cpp:
Warning W8004 gdipluss.cpp 150: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWRECT()
Warning W8004 gdipluss.cpp 174: 'pen' is assigned a value that is never used in
function HB_FUN_GDIPLUSDRAWELLIPSE()
Antonio , ¿ has mirado el enlace http://leandroascierto.com/blog/category/graficos/ ? .
Tiene un codigo para cargar una imagen en un formato ( “BMP, DIB, JPG, JPEG, JPE, JFIF, GIF, PNG, TIF, TIFF, EMF, WMF, ICO, CUR”. ) y pasarla a otro usando gdi+ que es buenisima .. http://leandroascierto.com/blog/modulo- ... -otro-gdi/
Re: documentacion de funciones gdi+
He añadido algo de código al archivo gdiplus.cpp ....
Para el archivo tgdiplus.prg ....
Code: Select all | Expand
HB_FUNC( GDIPLUSDRAWARC )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
Pen * pen = ( Pen * ) hb_parnl( 2 );
float nLeft = hb_parnd( 3 );
float nTop = hb_parnd( 4 );
float nWidth = hb_parnd( 5 );
float nHeight = hb_parnd( 6 );
float startAngle = hb_parnd( 7 );
float sweepAngle = hb_parnd( 8 );
graphics->DrawArc( pen, nLeft, nTop, nWidth, nHeight, startAngle, sweepAngle);
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSCREATEPATH )
{
hb_retnl( ( HB_LONG ) new GraphicsPath() );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDELETEPATH )
{
delete ( ( GraphicsPath * ) hb_parnl( 1 ) );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSPATHADDLINE )
{
GraphicsPath * graphicPath = ( GraphicsPath * ) hb_parnl( 1 );
float nLeft = hb_parnd( 2 );
float nTop = hb_parnd( 3 );
float nRight = hb_parnd( 4 );
float nBottom = hb_parnd( 5 );
graphicPath->AddLine( nLeft, nTop, nRight, nBottom ) ;
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDRAWPATH )
{
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
Pen * pen = ( Pen * ) hb_parnl( 2 );
GraphicsPath * graphicPath = ( GraphicsPath * ) hb_parnl( 3 );
graphics->DrawPath( pen, graphicPath );
}
HB_FUNC( GDIPLUSPENSETCLR )
{
Pen * pen = ( Pen * ) hb_parnl( 1 );
Color clr = Color( hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ) );
hb_retni( pen->SetColor( clr ) );
}
Para el archivo tgdiplus.prg ....
Code: Select all | Expand
CLASS Graphics
....
METHOD DrawArc( oPen, nLeft, nTop, nWidth, nHight,startAngle, sweepAngle ) INLINE ;
GdiPlusDrawArc( oPen:hPen, nLeft, nTop, nWidth, nHeight, startAngle, sweepAngle )
METHOD DrawPath( oPen, oPath ) INLINE GdiPlusDrawPath( oPen:hPen, oPath:hPath )
.....
CLASS Pen
...
METHOD SetColor( nTrans, nRed, nGreen, nBlue ) INLINE ;
GdiPlusPenSetClr( ::hPen, nTrans, nRed, nGreen, nBlue ) // nuevo methodo clase pen
.....
CLASS Path / nueva clase Path
DATA hPath
METHOD New()
METHOD Destroy()
METHOD AddLINE ( nLeft, nTop, nRight, nBottom ) INLINE GdiPlusPathAddLine( ::hPath, nLeft, nTop, nRight, nBottom )
DESTRUCTOR Destroy()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New() CLASS Path
::hPath = GdiPlusCreatePath()
return Self
//----------------------------------------------------------------------------//
METHOD Destroy() CLASS Path
GdiPlusDeletePath( ::hPath )
::hBrush = nil
return nil
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Manuel,
gracias por tu código
Acabo de ver esa página. Mas que nada lo que nos interesaria seria poder prescindir de la DLL FreeLibrary.dll
Eso sería fantástico para las aplicaciones FWH
Por eso me interesa GDI+ en primer lugar. Lo intentamos ?
gracias por tu código

Acabo de ver esa página. Mas que nada lo que nos interesaria seria poder prescindir de la DLL FreeLibrary.dll
Eso sería fantástico para las aplicaciones FWH

Por eso me interesa GDI+ en primer lugar. Lo intentamos ?

- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Está en tu enlace (ese no lo habia visto aún).
Solo tenemos que pasar ese código de Visual Basic a FWH !!!
Solo tenemos que pasar ese código de Visual Basic a FWH !!!

Re: documentacion de funciones gdi+
Tengo mas código gdi+ ... con esto ya coloco las imagenes en la ventana , incluyendo png transparentes .
También tiene código para grabar la imagen leída en cualquiera de los formatos soportados , por ahora tenemos TIF,GIF ,JPG,PNG ,BMP
...................... editado ....................................
He cambiado la clase Image a gdiImage y cambiado el codigo para facilitar el añadir mas formatos de imagen facilmente .
Tambien he añadido una función para convertir imagenes entre formatos ( entre los soportados).
para gdiplus.cpp
para tgdiplus (este codigo aún sin revisar ) :

También tiene código para grabar la imagen leída en cualquiera de los formatos soportados , por ahora tenemos TIF,GIF ,JPG,PNG ,BMP
...................... editado ....................................
He cambiado la clase Image a gdiImage y cambiado el codigo para facilitar el añadir mas formatos de imagen facilmente .
Tambien he añadido una función para convertir imagenes entre formatos ( entre los soportados).
para gdiplus.cpp
Code: Select all | Expand
HB_FUNC( GDIPLUSCREATEIMAGEFROMFILE )
{
Image * newImage = new Image( (LPCWSTR) hb_parc(1) );
hb_retnl( ( HB_LONG ) newImage );
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSDRAWIMAGE )
{
int iParams = hb_pcount();
Graphics * graphics = ( Graphics * ) hb_parnl( 1 );
Image * newImage = ( Image * ) hb_parnl( 2 );
int nLeft ;
int nTop ;
int nWidth ;
int nHeight;
switch (iParams){
case 4:
nLeft = hb_parni( 3 );
nTop = hb_parni( 4 );
graphics->DrawImage( newImage, nLeft, nTop );
case 6:
nLeft = hb_parni( 3 );
nTop = hb_parni( 4 );
nWidth = hb_parni( 5 );
nHeight = hb_parni( 6 );
graphics->DrawImage( newImage, nLeft, nTop,nWidth,nHeight);
}
}
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSIMAGESAVE )
{
Image * newImage = ( Image * ) hb_parnl( 1 );
CLSID cClsid ;
LPWSTR file = (LPWSTR) hb_parc(2);
LPWSTR identificador = (LPWSTR) hb_parc(3);
CLSIDFromString( identificador, &cClsid ) ;
newImage->Save( file , &cClsid, NULL);
}
para tgdiplus (este codigo aún sin revisar ) :
Code: Select all | Expand
//----------------------------------------------------------------------------//
METHOD DrawImage( oImage,nTop,nleft, nWidth, nHeight ) CLASS Graphics
if Empty(nWidth ) .or. Empty( nHeight )
GdiPlusDrawImage( ::hGraphics, oImage:hImage, nTop, nLeft )
else
GdiPlusDrawImage( ::hGraphics, oImage:hImage,nTop,nLeft, nWidth, nHeight )
endif
Return nil
//----------------------------------------------------------------------------//
HB_FUNC( GDIPLUSIMAGEFINALIZE )
{
Image * newImage = ( Image * ) hb_parnl( 1 );
newImage.Finalize();
}
...........
//----------------------------------------------------------------------------//
CLASS GDIImage
DATA hImage
DATA aCLSID
DATa aExtensions
METHOD New(cFile)
METHOD Destroy()
METHOD Save( cFile )
DESTRUCTOR Destroy()
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( cFile ) CLASS GDImage
::hImage = GdiPlusCreateImageFromFile( AnsiToWide( cFile ) )
::aExtIni := { "BMP", "JPG", "GIF", "TIF", "PNG" }
::aExtEnd := { "BMP", "JPG", "GIF", "TIF", "PNG" }
::aCLSID := { "{557CF400-1A04-11D3-9A73-0000F81EF32E}" ,;
"{557CF401-1A04-11D3-9A73-0000F81EF32E}" ,;
"{557CF402-1A04-11D3-9A73-0000F81EF32E}" ,;
"{557CF405-1A04-11D3-9A73-0000F81EF32E}" ,;
"{557CF406-1A04-11D3-9A73-0000F81EF32E}" ;
}
return Self
//----------------------------------------------------------------------------//
METHOD Save( cFile ) CLASS GDIImage
local cExtension := Upper(cFileExt(cFile))
local cCLSID
local nScan:= aScan( ::aExtEnd, cFile )
if nScan == 0
msginfo( "Formato no soportado" )
Return .f.
endif
cCLSID := aCLSID[ nScan ]
cCLSID = AnsiToWide( cCLSID )
cFile = AnsiToWide( cFile )
GdiPlusImageSave( ::hImage, cFile, cCLSID )
Return nil
//----------------------------------------------------------------------------//
METHOD Destroy() CLASS GDIImage
GdiPlusImageFinalize( ::hImage )
::hImage = nil
return nil
//----------------------------------------------------------------------------//
Function GDIPlusConvertImage( cImageIni, cImageEnd )
local cExtIni := Upper(cFileExt( cImageIni ))
local cExtEnd := Upper(cFileExt( cImageEnd ))
local oImage
local nScan
if cImageIni == cImageEnd
msginfo( "Error. La imagen inicial y final son la misma" )
Return .f.
endif
if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0
Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
return .f.
endif
if( nScan:= aScan( oImage:aExtEnd, cExtEnd )) == 0
Msginfo( " el archivo "+ cImageEnd + " tiene un formato no soportado")
return .f.
endif
oImage:= GDIImage():New( cImageIni )
oImage:Save( cImageEnd )
oImage:Destroy()
Return nil
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Manuel,
He empezado a revisar el código de conversión de ficheros, y este es el primer ejemplo que he construido:
Me aparece un 18. Ni idea aún de que es...
He empezado a revisar el código de conversión de ficheros, y este es el primer ejemplo que he construido:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local hBmp
MsgInfo( GdiPLoadImageFromFile( "..\bitmaps\five.bmp", @hBmp ) )
MsgInfo( hBmp )
return nil
DLL FUNCTION GdipLoadImageFromFile( cFileName AS LPSTR, hImage AS LONG ) AS LONG PASCAL ;
LIB "GdiPlus.dll"
Me aparece un 18. Ni idea aún de que es...

- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
el nombre del fichero tiene que estar en "wide" luego seguiriamos con:
sigue apareciendo el 18...
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local hBmp := 0
MsgInfo( GdiPLoadImageFromFile( AnsiToWide( "..\bitmaps\five.bmp" ), @hBmp ) )
MsgInfo( hBmp )
return nil
DLL FUNCTION GdipLoadImageFromFile( cFileName AS LPSTR, hImage AS LONG ) AS LONG PASCAL ;
LIB "GdiPlus.dll"
sigue apareciendo el 18...
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Asi paso a obtener un 2:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oGraphics := Graphics():New( 0 )
local hBmp := 0
MsgInfo( GdiPLoadImageFromFile( AnsiToWide( "..\bitmaps\five.bmp" ), @hBmp ) )
MsgInfo( hBmp )
return nil
DLL FUNCTION GdipLoadImageFromFile( cFileName AS LPSTR, hImage AS LONG ) AS LONG PASCAL ;
LIB "GdiPlus.dll"
- Antonio Linares
- Site Admin
- Posts: 42521
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 76 times
- Contact:
Re: documentacion de funciones gdi+
Parece que estos son los códigos de error de GdiPlus:
"Ok",
"GenericError",
"InvalidParameter",
"OutOfMemory",
"ObjectBusy",
"InsufficientBuffer",
"NotImplemented",
"Win32Error",
"WrongState",
"Aborted",
"FileNotFound",
"ValueOverflow",
"AccessDenied",
"UnknownImageFormat",
"FontFamilyNotFound",
"FontStyleNotFound",
"NotTrueTypeFont",
"UnsupportedGdiplusVersion",
"GdiplusNotInitialized",
"PropertyNotFound",
"PropertyNotSupported"
Por lo que el 18 era: "GdiplusNotInitialized"
y el 2 es: "InvalidParameter"
"Ok",
"GenericError",
"InvalidParameter",
"OutOfMemory",
"ObjectBusy",
"InsufficientBuffer",
"NotImplemented",
"Win32Error",
"WrongState",
"Aborted",
"FileNotFound",
"ValueOverflow",
"AccessDenied",
"UnknownImageFormat",
"FontFamilyNotFound",
"FontStyleNotFound",
"NotTrueTypeFont",
"UnsupportedGdiplusVersion",
"GdiplusNotInitialized",
"PropertyNotFound",
"PropertyNotSupported"
Por lo que el 18 era: "GdiplusNotInitialized"
y el 2 es: "InvalidParameter"
Re: documentacion de funciones gdi+
Antonio , Tienes ya una Funcion completa para convertir archivos ....
Code: Select all | Expand
Function GDIPlusConvertImage( cImageIni, cImageEnd )
local cExtIni := Upper(cFileExt( cImageIni ))
local cExtEnd := Upper(cFileExt( cImageEnd ))
local oImage
local nScan
if cImageIni == cImageEnd
msginfo( "Error. La imagen inicial y final son la misma" )
Return .f.
endif
oImage = GDIImage()-New( cImageIni )
if( nScan:= aScan( oImage:aExtIni, cExtIni )) == 0
Msginfo( " el archivo "+ cImageIni + " tiene un formato no soportado")
return .f.
endif
if( nScan:= aScan( oImage:aExtEnd, cExtEnd )) == 0
Msginfo( " el archivo "+ cImageEnd + " tiene un formato no soportado")
return .f.
endif
oImage:Save( cImageEnd )
oImage:Destroy()
Return nil
Last edited by mastintin on Fri Nov 21, 2014 4:13 pm, edited 1 time in total.