Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #7892 > unrolled thread
| Started by | paulus604@gmail.com |
|---|---|
| First post | 2015-03-22 08:44 -0700 |
| Last post | 2015-03-28 10:22 -0700 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Capture part of screen and save to disk (BMP/JPG) paulus604@gmail.com - 2015-03-22 08:44 -0700
Re: Capture part of screen and save to disk (BMP/JPG) JohnMartens <martens@tennishulp.info> - 2015-03-22 18:24 +0100
Re: Capture part of screen and save to disk (BMP/JPG) paulus604@gmail.com - 2015-03-22 13:23 -0700
Re: Capture part of screen and save to disk (BMP/JPG) JohnMartens <martens@tennishulp.info> - 2015-03-22 21:36 +0100
Re: Capture part of screen and save to disk (BMP/JPG) paulus604@gmail.com - 2015-03-28 10:22 -0700
| From | paulus604@gmail.com |
|---|---|
| Date | 2015-03-22 08:44 -0700 |
| Subject | Capture part of screen and save to disk (BMP/JPG) |
| Message-ID | <49962ac6-8b0c-4304-bf0d-d418de8206fb@googlegroups.com> |
Hello all,
I would like to save a part of a screen/window to a file.
Using the code below I asume the data is already in memory (tips are welcome).
// create a DC (device contaxt) for the screen and create
// a memory DC compatible to screen DC
hScrDC := CreateDC(PSZ(_CAST,"DISPLAY"), NULL_PSZ, NULL_PSZ , NULL_PSZ )
hMemDC := CreateCompatibleDC(hScrDC) //compatible to display device context
// get points of rectangle to grab
nX := lpRect.Left
nY := lpRect.top
nX2 := lpRect.right
nY2 := lpRect.bottom
// get screen resolution
xScrn := GetDeviceCaps(hScrDC, HORZRES)
yScrn := GetDeviceCaps(hScrDC, VERTRES)
//make sure bitmap rectangle is visible
IF nX < 0 ; nX := 0; ENDIF
IF nY < 0 ; nY := 0; ENDIF
IF nX2 > xScrn; nX2 := xScrn; ENDIF
IF nY2 > yScrn; nY2 := yScrn; ENDIF
nWidth := nX2 - nX
nHeight := nY2 - nY
// create a bitmap compatible with the screen DC
hBitmap := CreateCompatibleBitmap(hScrDC, nWidth, nHeight)
// select new bitmap into memory DC
hOldBitmap := SelectObject(hMemDC, hBitmap)
// bitblt screen DC to memory DC
BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY)
What next? How do I save the image.
Thanks for any help
Paul, Netherlands
[toc] | [next] | [standalone]
| From | JohnMartens <martens@tennishulp.info> |
|---|---|
| Date | 2015-03-22 18:24 +0100 |
| Message-ID | <memtpv$a48$1@dont-email.me> |
| In reply to | #7892 |
I;m using FabPaint and save with this funciotn. John _DLL FUNCTION DIBSaveAsJPEG(pWinBmp AS PTR, pszFName AS PSZ) AS VOID PASCAL:FabPaint.FabDIBSaveAsJPEG //p Save a DIB Object to a JPEG file //a <pWinBMp> Pointer to the DIB Object to save //a <pszFName> Name of the File to create //d This function will save the desired DIB Object as a JPEG file. //d This function only works for 32 bpp bitmaps at the moment, so as an internal enhancement it //d will try to copy the bitmap as 32 bpp if needed before saving. //d To retrieve the number of bit per pixel, use the DIBGetInfo() function, and in the returned structure, //d read the biBitCount member of the bmiHeader member. //j FUNCTION:DIBGetInfo paulus604@gmail.com schreef op 22-3-2015 om 16:44: > Hello all, > > I would like to save a part of a screen/window to a file. > Using the code below I asume the data is already in memory (tips are welcome). > > // create a DC (device contaxt) for the screen and create > // a memory DC compatible to screen DC > hScrDC := CreateDC(PSZ(_CAST,"DISPLAY"), NULL_PSZ, NULL_PSZ , NULL_PSZ ) > hMemDC := CreateCompatibleDC(hScrDC) //compatible to display device context > // get points of rectangle to grab > nX := lpRect.Left > nY := lpRect.top > nX2 := lpRect.right > nY2 := lpRect.bottom > // get screen resolution > xScrn := GetDeviceCaps(hScrDC, HORZRES) > yScrn := GetDeviceCaps(hScrDC, VERTRES) > //make sure bitmap rectangle is visible > IF nX < 0 ; nX := 0; ENDIF > IF nY < 0 ; nY := 0; ENDIF > IF nX2 > xScrn; nX2 := xScrn; ENDIF > IF nY2 > yScrn; nY2 := yScrn; ENDIF > nWidth := nX2 - nX > nHeight := nY2 - nY > // create a bitmap compatible with the screen DC > hBitmap := CreateCompatibleBitmap(hScrDC, nWidth, nHeight) > // select new bitmap into memory DC > hOldBitmap := SelectObject(hMemDC, hBitmap) > // bitblt screen DC to memory DC > BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY) > > What next? How do I save the image. > > Thanks for any help > Paul, Netherlands >
[toc] | [prev] | [next] | [standalone]
| From | paulus604@gmail.com |
|---|---|
| Date | 2015-03-22 13:23 -0700 |
| Message-ID | <1274648c-0289-4381-89fd-f1341a8ab71e@googlegroups.com> |
| In reply to | #7892 |
Thanks! I studied your solution, but I'm still struggling with what I have in the memory. I asume I have (after my earlier mentioned code) some kind of bitmap in memory stored. How can I access that and write it to disk?
[toc] | [prev] | [next] | [standalone]
| From | JohnMartens <martens@tennishulp.info> |
|---|---|
| Date | 2015-03-22 21:36 +0100 |
| Message-ID | <men91q$q4d$1@dont-email.me> |
| In reply to | #7895 |
Maybe this helps ?
John
METHOD ScreenDumpToFile(cFilename) CLASS Window
*
* method made by Geoff
LOCAL lSaved AS LOGIC
LOCAL hDIB AS PTR
LOCAL hDC AS PTR
LOCAL hBitmap AS PTR
LOCAL hOldBitmap AS PTR
LOCAL hMemDC AS PTR
LOCAL hWnd AS PTR
// created from multiple contributions via comp.lang.clipper.visual-objects
Default(@cFilename, "C:\Temp\Window.jpg")
hMemDC := CreateCompatibleDC(NULL)
hDC := GetDC(SELF:Handle())
hBitmap := CreateCompatibleBitmap(hDC, SELF:Size:Width,
SELF:Size:Height)
hOldBitmap := SelectObject(hMemDC, hBitmap)
ReleaseDC(hWnd,hDC)
//PRF_CLIENT is om alleen canvas te nemen
SendMessage(SELF:Handle(),WM_PRINT,DWORD(_CAST,hMemDC),PRF_NONCLIENT+PRF_CHILDREN+PRF_CLIENT+PRF_ERASEBKGND)
SelectObject(hMemDC,hOldBitmap)
hDIB := DIBCreateFromHBitmap(hBitmap)
IF hDIB != NULL_PTR
IF Instr('JPG', Upper(cFilename))
DIBSaveAsJPEG(hDIB, String2Psz(cFilename))
ELSE
DIBSaveAs(hDIB, String2Psz(cFilename))
ENDIF
lSaved := File(cFilename)
ENDIF
DeleteObject(hBitmap)
DeleteDC(hMemDC)
RETURN lSaved
paulus604@gmail.com schreef op 22-3-2015 om 21:23:
> Thanks! I studied your solution, but I'm still struggling with what I have in the memory. I asume I have (after my earlier mentioned code) some kind of bitmap in memory stored.
> How can I access that and write it to disk?
>
[toc] | [prev] | [next] | [standalone]
| From | paulus604@gmail.com |
|---|---|
| Date | 2015-03-28 10:22 -0700 |
| Message-ID | <37d399e1-cc7d-4f51-b0d4-5117c2bdc052@googlegroups.com> |
| In reply to | #7892 |
Hello all, The solution works great, BUT: PieObjects, TextObject, etc. disapear from the JPEG!? while Fixed Text p.e. shows on JPEG On screen it's all OK. What can I do? Greetings, Paul Op zondag 22 maart 2015 16:44:27 UTC+1 schreef paul...@gmail.com: > Hello all, > > I would like to save a part of a screen/window to a file. > Using the code below I asume the data is already in memory (tips are welcome). > > // create a DC (device contaxt) for the screen and create > // a memory DC compatible to screen DC > hScrDC := CreateDC(PSZ(_CAST,"DISPLAY"), NULL_PSZ, NULL_PSZ , NULL_PSZ ) > hMemDC := CreateCompatibleDC(hScrDC) //compatible to display device context > // get points of rectangle to grab > nX := lpRect.Left > nY := lpRect.top > nX2 := lpRect.right > nY2 := lpRect.bottom > // get screen resolution > xScrn := GetDeviceCaps(hScrDC, HORZRES) > yScrn := GetDeviceCaps(hScrDC, VERTRES) > //make sure bitmap rectangle is visible > IF nX < 0 ; nX := 0; ENDIF > IF nY < 0 ; nY := 0; ENDIF > IF nX2 > xScrn; nX2 := xScrn; ENDIF > IF nY2 > yScrn; nY2 := yScrn; ENDIF > nWidth := nX2 - nX > nHeight := nY2 - nY > // create a bitmap compatible with the screen DC > hBitmap := CreateCompatibleBitmap(hScrDC, nWidth, nHeight) > // select new bitmap into memory DC > hOldBitmap := SelectObject(hMemDC, hBitmap) > // bitblt screen DC to memory DC > BitBlt(hMemDC, 0, 0, nWidth, nHeight, hScrDC, nX, nY, SRCCOPY) > > What next? How do I save the image. > > Thanks for any help > Paul, Netherlands
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web