Manuel
Me tope con el SayImage de TPRINT que usa FreeImage.dll
Se puede con GDIPLUS?
Gracias por la ayuda
Saludos,
Adhemar
Function gPrnSayImage( oPrn, nRow, nCol, oImage, nWidth, nHeight, nRaster, lStretch, nAlphaLevel, nAlign )
local hDib, hPalBmp, hPal, nRatio, n, cImageBuf, lCreated := .f.
local hBmp, x, y
local ogbmp , cFile
DEFAULT nWidth := 0, nHeight := 0, lStretch := .t., nAlphaLevel := 255, nAlign := 1 // center
if oPrn:hDC = 0
return nil
endif
if ValType( oImage ) == 'C'
if File( oImage )
cFile:= oImage
// oImage := TImage():Define( , oImage )
oImage := TImage():Define( )
oGBmp:= GDIBmp():new(cFile)
oImage:hbitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:refresh()
//oGbmp:end()
lCreated := .t.
else
cImageBuf := oImage
oImage := TImage():Define()
oGBmp:= GDIBmp():new()
oGBmp:LoadFromStr( cImageBuf )
oImage:hbitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oImage:refresh()
//oGbmp:end()
// oImage:LoadFromMemory( cImageBuf )
lCreated := .t.
endif
endif
do case
case ValType( oImage ) == "O"
hDib = DibFromBitmap( oImage:hBitmap, oImage:hPalette )
otherwise
hDib = 0
endcase
if hDib = 0
return nil
endif
if ! oPrn:lMeta
hPal := DibPalette( hDib )
endif
x := nWidth; y := nHeight
// try to keep aspect ratio if only one size is passed in.
if nWidth == 0 .and. nHeight > 0 .and. ( n := oImage:nHeight() ) > 0
nRatio := oImage:nWidth() / n
x := int( nHeight * nRatio )
elseif nWidth > 0 .and. nHeight == 0 .and. ( n := oImage:nWidth() ) > 0
nRatio := oImage:nHeight() / n
y := int( nWidth * nRatio )
elseif nWidth > 0 .and. nHeight > 0 .and. ! lStretch
if ( nWidth / oImage:nWidth() ) < ( nHeight / oImage:nHeight() )
x := nWidth; y := oImage:nHeight() * ( nWidth / oImage:nWidth() )
else
y := nHeight; x := oImage:nWidth() * ( nHeight / oImage:nHeight() )
endif
if x < nWidth
if lAnd( nAlign, 1 ) // DT_CENTER = 1
nCol += Int( ( nWidth - x ) / 2 )
elseif lAnd( nAlign, 2 ) // DT_RIGHT = 2
nCol += ( nWidth - x )
endif
endif
if y < nWidth
if lAnd( nAlign, 4 ) // DT_VCENTER = 4
nRow += Int( ( nHeight - y ) / 2 )
elseif lAnd( nAlign, 8 ) // DT_BOTTOM = 8
nRow += ( nHeight - y )
endif
endif
endif
if oImage:HasAlpha()
hBmp := ResizeBmp( oImage:hBitmap, x, y )
ABPaint( oprn:hDCOut, nCol, nRow, hBmp, nAlphaLevel )
DeleteObject( hBmp )
else
DibDraw( oprn:hDCOut, hDib, hPal, nRow, nCol, x, y, nRaster )
endif
GlobalFree( hDib )
if ! oprn:lMeta
DeleteObject( hPal )
endif
if lCreated
oImage:End()
endif
return nil
//----------------------------------------------------------------------------//
Function gPrnSayImage( oPrn, nRow, nCol, oImage, nWidth, nHeight, nRaster, lStretch, nAlphaLevel, nAlign )
local hDib, hPalBmp, hPal, nRatio, n, cImageBuf, lCreated := .f.
local hBmp, x, y
local ogbmp, cfile
DEFAULT nWidth := 0, nHeight := 0, lStretch := .t., nAlphaLevel := 255, nAlign := 1 // center
if oPrn:hDC = 0
return nil
endif
if ValType( oImage ) == 'C'
if File( oImage )
cfile := oImage
oImage := TImage():Define( )
oGBmp:= GDIBmp():new(cFile)
oGbmp:resize( nWidth, nHeight )
oImage:hbitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oGbmp:end()
lCreated := .t.
else
cImageBuf := oImage
oImage := TImage():Define()
oGBmp:= GDIBmp():new()
oGBmp:LoadFromStr( cImageBuf )
oGbmp:resize( nWidth, nHeight )
oImage:hbitmap := oGBmp:GetGDIHbitmap()
oImage:HasAlpha()
oGbmp:end()
lCreated := .t.
endif
endif
do case
case ValType( oImage ) == "O"
hDib = DibFromBitmap( oImage:hBitmap, oImage:hPalette )
otherwise
hDib = 0
endcase
if hDib = 0
return nil
endif
if ! oprn:lMeta
hPal := DibPalette( hDib )
endif
if oImage:HasAlpha()
ABPaint( oprn:hDCOut, nCol, nRow, oimage:hBitmap, nAlphaLevel )
else
hDib = DibFromBitmap( oImage:hBitmap, oImage:hPalette )
DibDraw( oprn:hDCOut, hDib, hPal, nRow, nCol, nWidth, nHeight, nRaster )
endif
GlobalFree( hDib )
if ! oprn:lMeta
DeleteObject( hPal )
endif
if lCreated
oImage:End()
endif
return nil
//----------------------------------------------------------------------------//
acuellar wrote:Perfecto!!
Funciona
El único error de advertencia es:
Warning W8022 D:\SISTEMAS\COMPILER\BCC68\include\windows\GdiplusHeaders.h 636: 'Bitmap::Clone(const Rect &,int)' hides virtual function 'Image::Clone()'
Muchas gracias Manuel.
Saludos,
Adhemar
#pragma warn -hid // nuevo
#include "GdiPlus.h"
#pragma warn .hid // nuevo
cnavarro wrote:Manuel, en linea de comandos creo que seria -DSTRICT
https://community.embarcadero.com/index ... -is-strict
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 12 guests