Hi!

I'm a newbie in Win32ASM. I want display a 24bpp BMP in resource using StretchBlt.
The code works fine in win2k. But in win98se, It FAILED on LoadBitmap .

The BMP is some how 1.2MB.

I can't find someting helpful in MSDN and here.

May be, the size is too BIG?
I've test it with a 8bpp BMP. It works fine in both win98se and win2k.

I need some help on this.
The only thing I need is: display ANY BMP to screen in win98se and win2k both.

Thanks a lot.

The proc. is below
;DsrBlt
;Function: display a BMP to screen
;Enter:
; hDC Dest. HDC
; uID the ID of the BMP in resource
; dwLeft left of dest.
; dwTop top of dest.
; dwCx width of dest.
; dwCy height of dest.
;Return:
; N/A
DsrBlt3 proc hDC:HDC,uID:DWORD,dwLeft:DWORD,dwTop:DWORD,dwCx:DWORD,dwCy:DWORD
LOCAL hOld : HBITMAP
LOCAL memDC : HDC
LOCAL hBmp: HBITMAP
LOCAL bi : BITMAP

invoke LoadBitmap,hInstance,uID;it FAILED here in win98se with my
;24bpp*800*600 BMP, GetLastError gives 0. in w2k, it's fine

.IF eax!=0
mov hBmp,eax

invoke CreateCompatibleDC,hDC ; create memory device context
.IF eax!=0
mov memDC, eax
invoke GetObject,hBmp,SIZEOF BITMAP,addr bi;get info. of it
.IF eax!=0
;begin stretch
invoke SelectObject,memDC,hBmp
mov hOld,eax
invoke StretchBlt,hDC,dwLeft,dwTop,dwCx,dwCy,memDC,0,0,bi.bmWidth,bi.bmHeight,SRCCOPY
invoke SelectObject,memDC,hOld
.ENDIF
invoke DeleteObject,memDC
.endif
invoke DeleteObject,hBmp
.endif
invoke GetLastError
ret
DsrBlt3 endp
Posted on 2003-01-09 22:53:19 by DavidCat
I have made a prog that has a bunch of bitmaps which totalled about 1 meg.
AAs far as i can remember there was no problem on 95 98 2000nt

Maybe when the bmp is over a certain size you have to allocate memory. I don't really know.

Check for AllocationGranularity maybe. This has been hardcoded at 64k in the past but i don't know if it matters if your not allocating memory.

Sorry if i am no help.
Posted on 2003-01-09 23:50:21 by IwasTitan
To IwasTitan:

Thanks.

Maybe it's because of the size.
In my EXE, each size of the two BMP if above 1MB.

It works fine in win2k. But can't work in win98se.

I've found a peace of VC code about this and have try it under win98se. It works fine.

I'm trying to trans. it to ASM.

I'll post the code here after all is done.




:rolleyes:
Posted on 2003-01-09 23:57:53 by DavidCat
David,

If I remember rightly, win95 had a limit on the resource size you could load before some of the resource loading APIs failed. It is probably the case on win98 as well.

You could try the API LoadImage and load the file from disk otherwise, see if you can find Ernie Murphy's JPG to BMP routines as this will get far larger inages into a resource file before the limit is found.

Regards,

hutch@movsd.com
Posted on 2003-01-10 05:45:59 by hutch--
As hutch suggested you should either look at the jpeg lib or at Thomas' PNGlib (www.madwizard.org).
Posted on 2003-01-10 05:55:09 by bazik
there is also a tool from Microsoft, which fixes exe files with large resources. Its name is FIXRES.
Dont know where to find, just try to search at Microsoft. As far as I know this is only for Win95..
maybe Win98 has the same bug
Posted on 2003-01-10 05:56:56 by beaster
Thanks a lot for my good friends!

:)

Last Weekend, I have no more time to do with this. So I wrote a DLL in VC using some souce code of others, which is imp. with MFC.

The problem is resolved in VC. But I steel want to do it in MASM.

I'll try as soon as possible.

The basic method if that is using: FindResource, LoadResource,LockResource,CreateDIBSection,CreatePalette.

When everything is done, I'll post the code here!

Best regards.
Posted on 2003-01-12 19:07:42 by DavidCat
to beaster:


I've find the topic about FixRes in MSDN. The key words used for search is "FixRes".

Here is some information from MSDN on this topic.
Cause
When a 32-bit module is loaded into memory, Windows 95 and Windows 98 create a 16-bit version of the resources in the 32-bit module so that the resources can be accessed from 16-bit code. The "size" field of a 16-bit resource is only a 16-bit integer. Consequently, resources larger than 64K require special treatment.

Resolution
Following are two methods of working around this problem.

Method 1
Since the original 32-bit resources are not damaged, use those resources instead of the 16-bit resources. For example, to avoid a truncated dialog box, change the following code:
DialogBox(hInstance, lpTemplate, hwndParent, DialogProc);
-to-
// Error checking deleted for expository purposes.
HRSRC hrsrc = FindResource(hInstance, lpTemplate, RT_DIALOG);
LPCDIALOGTEMPLATE lpDlgTemplate = LoadResource(hInstance, hrsrc);
DialogBoxIndirect(hInstance, lpDlgTemplate, hwndParent, DialogProc);
Method 2
Artificially pad the resources so that the truncation performed by Windows 95 does not result in the loss of significant data. This can be performed after-the-fact by the FixRes95 tool (see the MORE INFORMATION section of this article to see how to obtain this tool). Note that since FixRes95 uses the UpdateResource APIs to modify the 32-bit image, it requires Windows NT to run. (The requirement for Windows NT applies only to the conversion program itself and not to the image file being converted.)

The FixRes95 tool is a console application that works off of command line parameters. To use FixRes95, use the following command line:
fixres95 [-a] <module name>
The -a is optional and, if specified, will force all resources to be updated.

The <module name> is the path and file name of the module whose resources will be updated.
Posted on 2003-01-12 22:04:01 by DavidCat
Fixres tell me the fix is done.

But it still failed in LoadBitmap.
GetLastError return 2.

I'll try the second way MS tello me.
Posted on 2003-01-12 22:51:26 by DavidCat