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

xiahan

also the Alpha part is unusable , cuz i didn't find a good way(any suggestion?) to let the user input a transparency value , so i initial the transparency value as 76.

edit: revision to achieve flicker-free and a test bitmap and a test bitmap


http://images.cjb.net/465f3.bmp

dedndave

quite often, they will use the color value of the pixel in the upper left corner of the image to identify the transparent color
you can use GetPixel to discover it's value, then use it with GdiTransparentBlt or to create a mask

xiahan

what i do is [Image'Color*x%+Background'Color*(100-x)%] to imitate the transparent ,

the target is the whole image,

and dave, what's your circumstance?

dedndave

Quoteand dave, what's your circumstance?

what do you mean ?

Gunner

He is not available if that is what you mean :-)  He is married.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

dedndave

lol
yah - semi-retired Electronics Engineer
married with a daughter

i have written software professionally in certain specialized cases - back in the DOS days and before
it's mainly a hobby

xiahan

oh my god!!!! what are you thinking about?

i just want to know in which situation will

the color value of the pixel in the upper left corner of the image to identify the transparent color

be functional , your 'transparent' is not the same with mine

so tell me which kind of picture can apply the method dave offers work?

dedndave

in this image...



the purple area can be made transparent to create icons

here is some example code...
http://www.masm32.com/board/index.php?topic=18800.0

there is one post in that thread where i use TransparentBlt
GdiTransparentBlt might be a better choice
and another where i create a mask to achieve the same thing

xiahan

yah,  maybe i used the wrong word to

drive you mad , lol

xiahan

Quote from: dedndave on May 21, 2012, 12:25:36 AM




the purple area can be made transparent to create icons

here is some example code...
http://www.masm32.com/board/index.php?topic=18800.0

there is one post in that thread where i use TransparentBlt
GdiTransparentBlt might be a better choice
and another where i create a mask to achieve the same thing

finish your example, the purple is replaced by the background color while the main image doesn't

change to let it look merged into the background, just cool !

but my code is to do what the Alpha channal does, make the image entirely looked transparent

dedndave


xiahan

Google says: (http://en.wikipedia.org/wiki/Alpha_compositing)

outRGB = srcRGBsrcA + dstRGB(1-srcA)

The value of alpha in the color code ranges from 0.0 to 1.0

the same as mine

[Image'Color*x%+Background'Color*(100-x)%]  x = alpha value

besides , any optimizition to my code

dedndave

"optimization" - there is always a way to optimize code - even after it has been optimizied - lol

it's looking better and better, each time

however, the program crashes if i try to open certain bmp files
not sure why that is, but it may be something to do with accessing addresses in the heap that aren't allocated

i would just work on general "clean-up"
i.e., organize the source code a little better, is all

we could use a second compatible DC in the WM_PAINT code to get rid of the flicker when sizing the window

xiahan

about the flicker i googled it and found is because i

set the CS_HREDRAW or CS_VREDRAW when i fill the WNDCLASSEX structure

besides every time my window is coverd by other window then it again get the focus to

display topmost it will flicker anyway

http://www.catch22.net/tuts/flicker-free-drawing the same as the article points out

the system first send the WM_ERASEBKGND ,then WM_PAINT, so the window flicked

but when i write this

.elseif uMsg == WM_ERASEBKGND
    .if hbmp
        mov eax,1
        jmp @f

    .endif
    xor eax,eax


it behaves flicker-free , but before i load a certain bmp , the bkgnd is already un-erased

why?

edit: i discover the reason ,cause i didn't call the DefWindowProc


xor eax,eax
jmp def
...
.else
def:
        invoke DefWindowProc,hWnd,uMsg,wParam,lParam
        ret


it seems in my wm_paint handler except paint the bmp , i have paint the rest bkgnd in the

PAINTSTRUCT retrieved by the beginpaint

xiahan

Quote from: dedndave on May 21, 2012, 12:00:54 PM
however, the program crashes if i try to open certain bmp files
not sure why that is, but it may be something to do with accessing addresses in the heap that aren't allocated
can you send me a sample bitmap with that problem yahoo-email:xia_han@yahoo.cn

Quote from: dedndave on May 21, 2012, 12:00:54 PM
i would just work on general "clean-up"
what do you mean