FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Save2bmp()
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Save2bmp()
Posted: Mon Feb 08, 2016 08:14 PM
Buenas tardes para todos....

He estado haciendo pruebas con la maravillosa clase tgraph, hasta ahora excelente y fácil de usar. Pero ahora se me presenta un nuevo reto, debo poder adjuntar las graficas en un reporte generado desde EasyReport. Buscando en el foro encontré que con el método Save2bmp, podría generar un archivo .bmp del grafico y
así seria fácil montarlo en el Reporte. Pero resulta que cuando grabo la imagen me genera un archivo con fondo gris, pero no muestra el grafico que se ve perfectamente en pantalla.

El código es el siguiente:

Code (fw): Select all Collapse
// Muestra gráfica de distribución de captura por día

#Include "FiveWin.Ch"

Static  oWnd  , nTot, nCan
Static  oGraph, aDia, aCan

Function Main()
   LOCAL cDate, aFld, cTotal
   Local cFile:="C:\Cartera\pictures\prueba.Bmp"

   SET DELETED ON
   SetHandleCount(99)
   nTot:=nCan:=0
   aDia:={}
   aCan:={}
   
   for n := 1 to 5
      AAdd(aDia,Str(n))
      AAdd(aCan,n)
      nCan++
   next

   DEFINE WINDOW oWnd FROM 1, 1 TO 20, 80 TITLE "Distribucion de captura"
   oGraph:=TGraph():New(0,0,oWnd,oWnd:nWidth()-8,oWnd:nHeight()-40)
   cTotal:="Total: "+Tran(nTot,"999,999")+" registros.         Promedio "+Tran(nTot/nCan,"999,999")
   oGraph:cPicture:="999,999"
   //oGraph:SetYVals(aDia)
   oGraph:cTitX   :="Volumen"
   oGraph:cTitY   :=cTotal
   oGraph:lYVal   :=.F.
   oGraph:lLegends:=.F.
   oGraph:lPopUp  :=.T.
   oGraph:AddSerie(aCan,"",RGB(128,128,255))

   ACTIVATE WINDOW oWnd ;
      ON PAINT (oGraph:nWidth:=oWnd:nWidth()- 8, ;
                oGraph:nHeight:=oWnd:nHeight-40, ;
                oGraph:Refresh(.t.),oGraph:Save2Bmp(cFile,0))


RETURN (NIL)

procedure AppSys  // Xbase++ requirement
return
Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Save2bmp()
Posted: Tue Feb 09, 2016 09:47 AM
leandro intenta usar esta función que usa gdi+ para grabarlo a ver si funciona.

Code (fw): Select all Collapse
 ....
 ACTIVATE WINDOW oWnd ;
      ON PAINT (oGraph:nWidth:=oWnd:nWidth()- 8, ;
                oGraph:nHeight:=oWnd:nHeight-40, ;
                oGraph:Refresh(.t.),SaveWindow( oWn:hWnd , "grafico.png") )

Function SaveWindow( hWnd, cImageEnd, nWidth , nHeight )

local hBitmap := WndBitmap( hWnd )
local oBmp:=GDIBmp():new()
     oBmp:CreateFromRes( hBitmap )
 //    oBmp:resize( nWidth , nHeight  )
     oBmp:Save( cImageEnd )
     oBmp:End()

Return nil
Posts: 1816
Joined: Wed Oct 26, 2005 02:49 PM
Re: Save2bmp()
Posted: Tue Feb 09, 2016 04:58 PM

Mastintin gracias por responder

Pruebo y comento.

Saludos

Saludos
LEANDRO AREVALO
Bogotá (Colombia)
https://hymlyma.com
https://hymplus.com/
leandroalfonso111@gmail.com
leandroalfonso111@hotmail.com

[ Turbo Incremental Link64 6.98 Embarcadero 7.70 ] [ FiveWin 25.01 ] [ xHarbour 64 bits) ]

Continue the discussion