hi, does anyone have an idea how to get maximum size (width and height) of a DIB, that can be created on a given machine?

i use the following code:

assumptions:
- hdc is a valid device context. i'm sure it's valid because it draws everything else with "Rectanlge()" and ohters

- hbitmem is a valid pointer do a BMP file in memory. i'm sure it's valid, because i check it after loading the file

the code:



push [hbitmem]
call CreateCompatibleDC, [hdc]
pop ecx
or eax, eax
jz handle_error
lea edx, [ecx+size BITMAPFILEHEADER] ;(14)
add ecx, [ecx+10] ; make ecx point to rgb field
mov [hmemDC], eax
call CreateDIBitmap, [hdc], edx, CBM_INIT, ecx, edx, 0
or eax, eax
jz handle_error
mov [hbitmap], eax
call [_SelectObject], [hmemDC], eax
call GetClientRect, [mywindowhandle], offset rect
call BitBlt, [hdc], 0, 0, [rect.right], [rect.bottom], [hmemDC], 0, 0, SRCCOPY



it works perfectly up to some image sizes, so i dont think it's my code's fault. i found out that this "some sizes" is 1088x715. up to this size everything is fine, but above that - strange things start to show up - blinking 'dirt' instead of the image, sometimes it's a part of the image followed by some dirt, sometimes it's the image with a strange mosaic effect. . etc, etc.

i also found out that above very large size (like 10'000x10'000) CreateDIBitmaps starts to fail by returning 'null', which (i think) should be returned earlier.

is it a driver bug? or windows'? or mine? :P is there any way to determine maximum size, which will work fine on all machines?

to complete the question: my machine is pentium4 2.4GHz, Geforce4 Ti 4200 (nvidia detonators 61.77), 1GHz of RAM. desktop resolution 1024/768
Posted on 2004-11-20 19:12:17 by ti_mo_n
The maximum DIB/Bitmap size depends on the available free memory

Otherwise 32768x32768 is the maximum on Win98SE AFAIK

Also i think there is no limit on Win2k and WinXP ... other then the memory size and the practicall issue of extreemly low speed.

With huge things it is better if you handle them by hand in asm :)
Posted on 2004-11-21 04:09:37 by BogdanOntanu
If I remember correctly CreateDIBitmaps had a bug in some platforms when usining very large images.
Posted on 2004-11-21 14:53:55 by QvasiModo
i think it cant be bypassed in any way :/ the function (CreateDIBitmap) returns a valid handle, but when i use this handle 'funny stuff' is being rendered. so i gave up on supporting hires images.

now i have another problem

call	[_CreateCompatibleDC], [PSS.hdc]

push eax
mov ecx, [hbitmem]
lea edx, [ecx+size BITMAPFILEHEADER];14
add ecx, [ecx+10]
call [_CreateDIBitmap], eax, edx, CBM_INIT, ecx, edx, edi
pop ecx ;hdc
push eax ;hbit
push ecx ;hdc
call [_SelectObject], ecx, eax;[hbitmap2]
pop ecx ;hdc
push ecx ;hdc
push eax ;previous object
call [_BitBlt], [PSS.hdc], 0, 0, 200, 200, ecx, 0, 0, SRCCOPY
pop edx ;previous object
pop eax ;hdc
call [_SelectObject], eax, edx
push eax ;hdc
pop ecx ;hbit
push eax ;hdc
call [_DeleteObject], ecx
call [_DeleteDC]


ALL of the above functions SUCCEED (they return valid handles or TRUE), but they render only black rectangle 200x200 starting from point (0, 0)...and im sure, that my bitmap is not a black rectangle :P PSS.hdc i a valid device contect retrieved using 'BeginPaint'. it's just a test code, so dont look at its lack of optimization :P

any ideas why it draws just a black rectangle, when all functions succeed?

....eh, i think i'll go back to DX world... and never tell me, that DX is harder than winAPI :P DX at least works :P
Posted on 2004-11-22 11:59:21 by ti_mo_n