- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi folks,
I hope there is an expert on Win32 API who could help me with a frustrating problem.
I have developed a subroutine which prints a monochrome version of a rectangular section of the screen.
A test version of the code runs like this:
On Win NT 4.0 everything works perfectly in all cases.
On Win 95 or 98 it only works when the width of the selected screen rectangle is divisible by 32, i.e when no "zero padding" is required in constructing the IM_1 bitmap part.
When zero-padding is required, the image is totally "scrambled" showing that the created bitmap is "out of sync".
Any suggestions ???
Thanks
lars.engstrom@fysik.lu.se
I hope there is an expert on Win32 API who could help me with a frustrating problem.
I have developed a subroutine which prints a monochrome version of a rectangular section of the screen.
A test version of the code runs like this:
- Capture the screen using GETIMAGE.
- Convert the resulting 32-bit bitmap to a monochrome 1-bit bitmap, the DATA PART of which is stored in array IM_1 (i.e no header or RGB colors)
- Start using Win-32 routines
BM.bmType=0 BM.bmWidth=ICOLTOT BM.bmHeight=IROWTOT BM.bmWidthBytes=NBYTE_ROW BM.bmPlanes=1 BM.bmBitsPixel=1 BM.bmBits=LOC(IM_1) hBM=CreateBitmapIndirect(BM) ! create win-32 bitmap structure hDCsc=CreateDC(DISPLAY,char(0),char(0),DV) ! Normal DC for screen hDCscComp=CreateCompatibleDC(hDCsc) ! memory screen IRES=SelectObject(hDCscComp,hBM) ! select mono bitmap ! As a test, copy mono image back to the real screen ires=BitBlt(hDCsc,100,100,ICOLTOT,IROWTOT, + hDCscComp,0,0,SRCCOPY)
On Win NT 4.0 everything works perfectly in all cases.
On Win 95 or 98 it only works when the width of the selected screen rectangle is divisible by 32, i.e when no "zero padding" is required in constructing the IM_1 bitmap part.
When zero-padding is required, the image is totally "scrambled" showing that the created bitmap is "out of sync".
Any suggestions ???
Thanks
lars.engstrom@fysik.lu.se
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, the docs on BITMAP say, quote,
The bitmap formats currently used are monochrome and color. The monochrome bitmap uses a one-bit, one-plane format. Each scan is a multiple of 32 bits.
Maybe it's not true for WinNT/2000, since GDI realizations btw. 9x and
NT do differ, however, it looks as if you'll have to redesign the code so that
BM.bmHeight is a multiply of 32. Well, it will require some conversion btw.
real image size (in general, not a multiply of 32) and 32-bit based memory representation, but I'm afraid you can't avoid that.
Jugoslav
The bitmap formats currently used are monochrome and color. The monochrome bitmap uses a one-bit, one-plane format. Each scan is a multiple of 32 bits.
Maybe it's not true for WinNT/2000, since GDI realizations btw. 9x and
NT do differ, however, it looks as if you'll have to redesign the code so that
BM.bmHeight is a multiply of 32. Well, it will require some conversion btw.
real image size (in general, not a multiply of 32) and 32-bit based memory representation, but I'm afraid you can't avoid that.
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,Lars again.
I have "solved" the problem - although I don't understand the solution!!
The trick is to make the number of bytes per scan line (row) divisible by TWO (2). Then everyting works on all platforms.
However, every doc on bitmaps I have ever seen, incl SDK, states that you must pad to make the number of bytes divisible by FOUR (4) - word aligned.
I would still be happy if someone could help me understand this
I have "solved" the problem - although I don't understand the solution!!
The trick is to make the number of bytes per scan line (row) divisible by TWO (2). Then everyting works on all platforms.
However, every doc on bitmaps I have ever seen, incl SDK, states that you must pad to make the number of bytes divisible by FOUR (4) - word aligned.
I would still be happy if someone could help me understand this
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page