News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

large bmp file

Started by sudeer, November 14, 2008, 09:58:50 AM

Previous topic - Next topic

sudeer

hi.... evry body
i am writing a program to show over 600 picture "bmp", i do not want to use the resource file because it takes a lot of memory
what is the best way to show them.                                             thanks

ragdog

Hi

I think this is a good way from masm32lib BitmapFromFile.

Invoke BitmapFromFile,addr Filename

Greets



MichaelW

sudeer,

Are you asking what is the best way to show them, or the best way to store them?
eschew obfuscation

Vortex

sudeer,

Probably, the best method is to not store the images as resources but to load and display each bmp file. This Masm32 example is a good one :

\masm32\examples\exampl02\showdib

sudeer

hi...........what i ment is to show them, if i use the normal way, i end up with 125 MB file size and i am using only 200 bmp's.
what if i use 600 bmp's i am going to end up with more than 375 MB file size, which is very large file.

ShowPage proc uses eax ebx numb:dword
   m2m      ebx,numb
   .if      ebx <= 222*4               
   invoke   LoadBitmap,hInstance,Q_BMP[ebx]
   mov      hBmp1,eax
   invoke   ShowBmp,hBmp1,hBmpPage
   .endif
   ret
ShowPage endp

ShowBmp proc uses eax ebx esi hBmp:dword,hwin:dword
   invoke   GetDC,hwin
   m2m      ebx,eax
   invoke   CreateCompatibleDC,eax
   m2m      esi,eax
   invoke   SelectObject,eax,hBmp
   invoke   GetClientRect,hwin,addr rc
   ;invoke   BitBlt,ebx,0,0,rc.right,rc.bottom,esi,0,0,SRCCOPY      ;Copy the bitmap
   invoke   StretchBlt,ebx,0,0,rc.right,rc.bottom,esi,0,0,386,560,SRCCOPY
   invoke   DeleteDC,esi
   invoke   ReleaseDC,hwin,ebx
   xor      eax,eax
   mov      PageFlag,1
   ret
ShowBmp endp


Vortex

Hi sudeer,

If I understand correctly, you are stroring all your bitmaps in the resource section. With a lot of image files, you will have an oversized executable. You should load your images from disc and then display them using image functions like BitmapFromFile.

Mark Jones

Also, consider compressing each image from a Bitmap into a JPEG file, if a very slight loss in quality is acceptable. This could easily reduce the amount of space taken by the images by 85% or more. Of course, there are times when the highest image quality must be maintained (medical imaging for example.) In that case, try the PNG compression algorithm. PNG gets less compression, but can be less lossy. Experiment, see which one works best for you.

Chris has posted some code to read JPG and PNG images from resources:
http://www.masm32.com/board/index.php?topic=10191.0
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

MichaelW

Or if the bitmaps are simple graphic images or similar, rather than photographs, in most cases you can use lossless compression (ZIP, RAR, GZIP, etc) to reduce the amount of space taken by the images substantially below that which would be required for a JPEG, with no loss of image quality.

eschew obfuscation


Mark Jones

JJ, I say "less lossy" because often, in the case of PNG data, 256 or less colors are used along with a dither. This results in very good (perceivable) quality with filesizes approaching that of JPG, while eliminating the macro-block visual artifacting of JPEG.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

jj2007

Quote from: Mark Jones on November 15, 2008, 10:15:47 PM
JJ, I say "less lossy" because often, in the case of PNG data, 256 or less colors are used along with a dither. This results in very good (perceivable) quality with filesizes approaching that of JPG, while eliminating the macro-block visual artifacting of JPEG.

Which means the loss occurs before the (lossless) png processing.

Mark Jones

Oh god, here we go again...
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Mark Jones

#12
whoops, double-post.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

sudeer

hi.....,yes
all my bitmaps in the resource section. With a lot of image files, i whould like first to try loading my images from disc and then display them using image functions like BitmapFromFile......?
how can i do that..........................an example whould better                        thanks a lot

hutch--

sudeer,

You should be able to use the LoadImage() API function if the file is a genuine Windows bitmap. What I don't remember is if it will load a 24 or 32 bit image, especially if the latter has a transparency channel by I occaionally use that function for loading 24 bit gradient fills as bitmaps and it seems to work fine. The virtue of LoadImage() is that you can load an image from a freestanding bitmap file so your executable does not blow out in size by including the images in its resources.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php