Clipper On Line • Ver Tópico - Captura de Tela com JPG.dll
Mudar para estilo Clássico
Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.
Postar uma resposta

Captura de Tela com JPG.dll

17 Abr 2018 13:06

Pessoal,

Não sei se tem exemplo usando JPG.dll para captura de tela (savescreen) para arquivo, segue contribuição.
h-JPG.zip
Função para captura de tela em disco
(808.69 KiB) Baixado 121 vezes


Código:
#include "hbdyn.ch"

FUNCTION MAIN()

   hwg_MsgInfo( "Teste com captura de tela" )
   
   FOTO( "TESTE2.JPG")

RETURN Nil

FUNCTION FOTO( cImagem )

nHandleDLL := Hb_LibLoad("JPG.dll")

   nStatus:=hb_dynCall( { "SaveToJpgEx", nHandleDLL, HB_DYN_CALLCONV_STDCALL}, 0, cImagem, 1024, 768)

   Hb_LibFree(nHandleDLL)

RETURN Nil

TESTE2.JPG

Captura de Tela com JPG.dll

17 Abr 2018 13:19

A função pode ser útil para capturar tela com erro, ou até ser um espião do sistema (rs)

Captura de Tela com JPG.dll

17 Abr 2018 13:32

Usando GT*

Código:
FUNCTION FOTO( cImagem )

nHandleDLL := Hb_LibLoad("JPG.dll")

   nWidth  := hb_gtInfo(HB_GTI_DESKTOPWIDTH )
   nHeight := hb_gtInfo(HB_GTI_DESKTOPHEIGHT )
   
   nStatus:=hb_dynCall( { "SaveToJpgEx", nHandleDLL, HB_DYN_CALLCONV_STDCALL}, 0, cImagem, nWidth, nHeight)

   Hb_LibFree(nHandleDLL)

RETURN Nil

Captura de Tela com JPG.dll

17 Abr 2018 13:43

Tem utilitário interessante neste link:

http://www.nirsoft.net/utils/dll_export_viewer.html

Captura de Tela com JPG.dll

18 Abr 2018 10:17

Foi feito com Harbour ?

Testei com xHB e não tem a função hb_dynCall()

Paulo

Captura de Tela com JPG.dll

18 Abr 2018 10:19

Harbour 3.2 e 3.4 mais atual

Captura de Tela com JPG.dll

18 Abr 2018 10:59

Usando um contador para gerar o jpg

Código:
FUNCTION FOTO()
THREAD STATIC nCounter := 1

   cCounter := "0001"
   
   nHandleDLL := Hb_LibLoad( "JPG.dll" )

   nWidth  := Hb_gtInfo( HB_GTI_DESKTOPWIDTH )
   nHeight := Hb_gtInfo( HB_GTI_DESKTOPHEIGHT )
   
   nWidth  := Hwg_GetDeskTopWidth()
   nHeight := Hwg_GetDeskTopHeight()
   
   IF Hb_FileExists( Hb_DirBase() + "JPG.INI" )
      cCounter := hwg_GetIni( 'CONTADOR', 'Counter', '', Hb_DirBase() + "JPG.INI" )
      nCounter := Val( cCounter )
   ENDIF

   cFile := cCounter + [.JPG]

   DO WHILE Hb_FileExists( cFile )
      cCounter := StrZero( nCounter++, 4 )
      cFile := cCounter + [.JPG]
   ENDDO
   
   nStatus:=hb_dynCall( { "SaveToJpgEx", nHandleDLL, HB_DYN_CALLCONV_STDCALL}, 0, cFile, nWidth, nHeight )

   hwg_WriteIni( 'CONTADOR', 'Counter', cCounter, Hb_DirBase() + "JPG.INI" )
   
   Hb_LibFree( nHandleDLL )

RETURN Nil

Captura de Tela com JPG.dll

18 Abr 2018 11:26

Só lembrando que a Bostaurus da HMG3 faz isso, o que dispensa DLL adicional.
Vai depender do que mais estiver usando, que pode dar conflito com a LIB da HMG3.

Captura de Tela com JPG.dll

18 Abr 2018 18:36

Esse exemplo que eu postei tem na Minigui Ex.

Eu adaptei para ser usado com harbour puro.

Na minigui tem um exemplo:

\MiniGUI\SAMPLES\Applications\ScreenshotMaker

Bitmap é um arquivo maior, por isso escolhi a função que eu postei, eu queria também poder gerar png mas não achei exemplo. acho que nesse caso posso usar a freeimage para converter de jpg para png

Captura de Tela com JPG.dll

19 Abr 2018 00:09

Internamente BT trabaja con bitmap porque el api de Windows trabaja con bitmap, pero BT lee y grava en otros formatos sin necesidad de Dll o alguna otra lib externa, ver la documentación:
http://www.hmgforum.com/hmgdoc/BosTauru ... eGuide.htm

BT_BitmapLoadFile (cFileName)

Loads an image (BMP, JPG, GIF, TIF or PNG) from the disk or resources and returns a handle to bitmap format image (hBitmap).

cFileName: is the name of the file or of the resource that contains the image.





BT_BitmapLoadEMF (cFileName, aRGBcolor_Fill_Bk, NewWidht, NewHeight, Mode_Stretch)

Loads an EMF (Enhanced Meta File) image from the disk or resources and returns a handle to bitmap format image (hBitmap).

cFileName: is the name of the file or of the resource that contains the image.

aRGBcolor_Fill_Bk: array containing the RGB colors that paint the background of the bitmap. For default: aRGBcolor_Fill_Bk = {0,0,0} = BLACK.

New_Width, New_Height: is the new size of the bitmap image. For default this values are the original width and height of the EMF image.

Mode_Stretch: sets the mode as the image of origin is adjusts (is stretches or compresses) in the new size bitmap, it is one of the constants: BT_SCALE or BT_STRETCH (defined in BosTaurus.CH). For default Mode_Stretch = BT_STRETCH.





BT_BitmapSaveFile (hBitmap, cFileName, nTypePicture)

Save an image (BMP, JPG, GIF, TIF or PNG) in the disk.

hBitmap: is a handle to the bitmap image.

cFileName: is the name of the file to save.

nTypePicture: specifies the format in which you want to save the image, it is one of the constants: BT_FILEFORMAT_BMP, BT_FILEFORMAT_JPG, BT_FILEFORMAT_GIF, BT_FILEFORMAT_TIF or BT_FILEFORMAT_PNG (defined in BosTaurus.CH). For default nTypePicture = BT_FILEFORMAT_BMP.

Captura de Tela com JPG.dll

19 Abr 2018 15:15

Para pegar o handle da janela você pode usar:

Hb_gtInfo( HB_GTI_WINHANDLE )

Captura de Tela com JPG.dll

19 Abr 2018 19:41

_HMG_SYSDATA é onde a HMG salva toda informação sobre janelas/controles.
Talvez isolar essas funções mais específicas, que tratam do ambiente HMG, pra retirar da Bostaurus.

Senão... acrescentar HMG só pra poder usar Bostaurus.

Captura de Tela com JPG.dll

19 Abr 2018 20:13

Consegui isolar a BosTaurus

Captura de Tela com JPG.dll

19 Abr 2018 21:00

O código está isolado, não precisa compilar com a MIniGui, vai precisar somente apontar para o arquivo que está no zip, mgdesfs.h porque o fonte
BosTaurus_C.prg precisa das definições contidas neste arquivo, é só apontar o INCPATH para a pasta da compilação ou colocar na pasta INCLUDE do harbour.

Código:
#define BT_BITMAP_CAPTURE_DESKTOP     0

#define BT_FILEFORMAT_BMP  0
#define BT_FILEFORMAT_JPG  1
#define BT_FILEFORMAT_GIF  2
#define BT_FILEFORMAT_TIF  3
#define BT_FILEFORMAT_PNG  4

* HwGui
hBitmap := BT_BMP_CAPTURESCR(0, 0, 0, Hwg_GetDeskTopWidth(), Hwg_GetDeskTopHeight(), BT_BITMAP_CAPTURE_DESKTOP)

* GTWVG / GTWVT
hBitmap := BT_BMP_CAPTURESCR(0, 0, 0, Hb_gtInfo( HB_GTI_DESKTOPWIDTH ), Hb_gtInfo( HB_GTI_DESKTOPHEIGHT ), BT_BITMAP_CAPTURE_DESKTOP)

lSucesso := BT_BMP_SAVEFILE( hBitmap, 'TESTE.BMP', BT_FILEFORMAT_BMP )

Anexos
BOS.zip
Copiado do código original do Dr. Claudio Soto
(1.04 MiB) Baixado 95 vezes

Captura de Tela com JPG.dll

19 Abr 2018 21:00

Si vas a compilar en ANSI en 32 bits se puede sustituir
las directivas HMG_parnl y HMG_parc

Poner al inicio del archivo en C:

#define HMG_parnl hb_parnl
#define HMG_parc hb_parc

Si no se utilizas HMG, sustituir
GetFormHandle()

por:
Hb_gtInfo( HB_GTI_WINHANDLE ) o alguna otra función que retorne el handle de las ventanas.

Además eliminar las funciones:
BT_HMGGetImage
BT_HMGCloneImage
BT_HMGSetImage

que son sólo para HMG.
Postar uma resposta