News:

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

bmp viewer wish your optimizing

Started by xiahan, May 20, 2012, 09:07:37 PM

Previous topic - Next topic

dedndave

by general clean-up, i mean better organize the flow of the source
for example, the INC files and the preamble are a bit out of whack   :P
.386
.model flat,stdcall
option casemap:none

Viewer proto :DWORD,:DWORD,:DWORD,:DWORD
;
;
SaveBmp proto

include bmp.inc

.code
start:

then, in bmp.inc...
include variables.inc
pixel_offset struct
;
;

.code

then, in variables.inc...
.data
ClassName db "BmpView",0
;
;
;
lPixel dw 3

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\comdlg32.inc
include \masm32\include\gdi32.inc
include \masm32\include\comctl32.inc

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\comdlg32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\comctl32.lib

.data?
hInstance        dd ?

:bg
it's like a jig-saw puzzle with a couple pieces missing

look at some of the example programs to see how they are organized

as for erasing the background, i will tell you a little trick i use   :U

make a child window with no caption or borders for the image to be displayed in
you really only need 3 style flags: WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS
when you load an image, size the child window to the same size as the image
when you register the class for the child, use NULL as the brush handle
the background will never be seen
if you have no image, hide the child window
in the child window WndProc, the only messages you have to handle is WM_PAINT and WM_CLOSE
in the WndProc for the main window, you do not have to handle WM_PAINT
so - it's basically moving some code around a little and registering a class   :P
you can also get rid of the code in WM_PAINT that takes the lesser of the image size and the rcPaint size

dedndave

here are a couple files - one is 256-color - the other is 16-color
one causes the program to crash - the other does not display