Hi, !
Using the FW Save Screen() function, I cut out a certain number of identical fragments from the screen. Then I need to glue them together in a certain order (like puzzles - top, bottom, right, left) and save them to a bitmap file. How can this be done ?
Gluing images
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Gluing images
#define SRCCOPY 13369376
local hDC := oDlg:GetDC()
local hDCMem := CreateComtatibleDC( hDC )
local hBitmap := CreateCompatibleBitmap( hDCMem, nWidth, nHeigth )
local hPrev := SelectObject( hDCMem, hBitmap )
local hBmp, hDib
now you paint your bitmaps on hDCMem this way:
hBmp = ReadBitmap( 0, "name.bmp" )
PalBmpDraw( hDCMem, nRow, nCol, hBmp )
Finally you save it and clean:
DibWrite( cFileName, DibFromBitmap( hBitmap ) )
SelectObject( hDCMem, hPrev )
DeleteObject( hBitmap )
DeleteDC( hDCMem )
oDlg:ReleaseDC()
local hDC := oDlg:GetDC()
local hDCMem := CreateComtatibleDC( hDC )
local hBitmap := CreateCompatibleBitmap( hDCMem, nWidth, nHeigth )
local hPrev := SelectObject( hDCMem, hBitmap )
local hBmp, hDib
now you paint your bitmaps on hDCMem this way:
hBmp = ReadBitmap( 0, "name.bmp" )
PalBmpDraw( hDCMem, nRow, nCol, hBmp )
Finally you save it and clean:
DibWrite( cFileName, DibFromBitmap( hBitmap ) )
SelectObject( hDCMem, hPrev )
DeleteObject( hBitmap )
DeleteDC( hDCMem )
oDlg:ReleaseDC()
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Gluing images
Code: Select all | Expand
function StitchCrops()
local hWnd, hBmp1, hBmp2, hBmp3, hNew
hWnd := GetDeskTopWindow()
hBmp1 := FWSaveScreen( hWnd, 200,200,400,300 ) // 100x200
hBmp2 := FWSaveScreen( hWnd, 700,650,900,950 ) // 300x200
hBmp3 := FWSaveScreen( hWnd, 500,500,650,900 ) // 400x150
hNew := FW_MakeYourBitmap( 400, 350, <|hDC|
FW_DrawImage( hDC, hBmp1, { 0, 0, 200, 100 } )
FW_DrawImage( hDC, hBmp2, { 0, 100, 200, 400 } )
FW_DrawImage( hDC, hBmp3, { 200, 0, 350, 400 } )
return nil
> )
FW_SaveImage( hNew, "new.bmp" )
DeleteObject( hNew )
XImage( "new.bmp" )
return nil
![Image](https://imagizer.imageshack.com/v2/xq90/924/30tCVV.png)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Gluing images
Rao, thank you very much !!! It can be printed in any format. And ate the picture in the size of the screen and if wider too
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Gluing images
It can be printed in any format.
Can be saved in any format.
And ate the picture in the size of the screen and if wider too
As the name itself indicates, FWSaveScreen() can extract full or part of what is visible on the screen only and nothing outside the screen.
But the resulting glued image can be larger than the screen.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Gluing images
To use the FW Save Screen() function to print a container larger than the screen, you need to move this container using the :Move method to the screen. Then you can always read the device context of the required fragment. I printed out the map in A1, A0 formats (but there are some subtleties here by synchronously zooming in on the map)
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Gluing images
Natter wrote:To use the FW Save Screen() function to print a container larger than the screen, you need to move this container using the :Move method to the screen. Then you can always read the device context of the required fragment. I printed out the map in A1, A0 formats (but there are some subtleties here by synchronously zooming in on the map)
YOU ARE RIGHT
I did not suggest this because it is complex.
But glad you found it and did it
![Smile :)](./images/smilies/icon_smile.gif)
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Gluing images
To read the device context, you need to fix the screen. What is the best way to do it ?
You can, of course, display msginfo() after each execution of :Move, but it's not pretty
You can, of course, display msginfo() after each execution of :Move, but it's not pretty