Hi there I really need help with this I do not know were to start .... as the title says I need to flip images vertically in memory after loading them ...how to do that ....
I searched the forum and found this
http://www.masm32.com/board/index.php?topic=18799.0
but the Example does not work for me ....
What I am trying to do is flip the images after loading them in this Example ... thank you !
( it is for the Areo Glass with Glow buttons :) )
StretchBlt will work
just make the sign of the source vertical size the opposite of the destination vertical size
VFlipBmp proc uses esi hBitmap:HBITMAP
LOCAL bmp:BITMAP
LOCAL hMemDC1:HDC
LOCAL hBmp1:HBITMAP
LOCAL hMemDC2:HDC
LOCAL hBmp2:HBITMAP
.if rv(GetObject,hBitmap,SIZEOF bmp,ADDR bmp)
mov esi,rv(GetDC,rv(GetDesktopWindow))
mov hMemDC1,rv(CreateCompatibleDC,esi)
mov hBmp1,rv(SelectObject,hMemDC1,rv(CreateCompatibleBitmap,esi,bmp.bmWidth,bmp.bmHeight))
mov hMemDC2,rv(CreateCompatibleDC,esi)
mov hBmp2,rv(SelectObject,hMemDC2,hBitmap)
invoke ReleaseDC,rv(GetDesktopWindow),esi
mov edx,bmp.bmWidth
mov ecx,edx
neg edx
dec ecx
invoke StretchBlt,hMemDC1,ecx,0,edx,bmp.bmHeight,hMemDC2,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY
invoke BitBlt,hMemDC2,0,0,bmp.bmWidth,bmp.bmHeight,hMemDC1,0,0,SRCCOPY
invoke DeleteObject,rv(SelectObject,hMemDC1,hBmp1)
invoke DeleteDC,hMemDC1
invoke SelectObject,hMemDC2,hBmp2
invoke DeleteDC,hMemDC2
.endif
ret
VFlipBmp endp
HFlipBmp proc uses esi hBitmap:HBITMAP
LOCAL bmp:BITMAP
LOCAL hMemDC1:HDC
LOCAL hBmp1:HBITMAP
LOCAL hMemDC2:HDC
LOCAL hBmp2:HBITMAP
.if rv(GetObject,hBitmap,SIZEOF bmp,ADDR bmp)
mov esi,rv(GetDC,rv(GetDesktopWindow))
mov hMemDC1,rv(CreateCompatibleDC,esi)
mov hBmp1,rv(SelectObject,hMemDC1,rv(CreateCompatibleBitmap,esi,bmp.bmWidth,bmp.bmHeight))
mov hMemDC2,rv(CreateCompatibleDC,esi)
mov hBmp2,rv(SelectObject,hMemDC2,hBitmap)
invoke ReleaseDC,rv(GetDesktopWindow),esi
mov edx,bmp.bmHeight
mov ecx,edx
neg edx
dec ecx
invoke StretchBlt,hMemDC1,0,ecx,bmp.bmWidth,edx,hMemDC2,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY
invoke BitBlt,hMemDC2,0,0,bmp.bmWidth,bmp.bmHeight,hMemDC1,0,0,SRCCOPY
invoke DeleteObject,rv(SelectObject,hMemDC1,hBmp1)
invoke DeleteDC,hMemDC1
invoke SelectObject,hMemDC2,hBmp2
invoke DeleteDC,hMemDC2
.endif
ret
HFlipBmp endp
i didn't test it, but this should work
VertFlip PROTO :HBITMAP
;**************************************************************************************************
VertFlip PROC hbmpInput:HBITMAP
;Creates a bitmap that is vertically flipped.
;If there is an error, EAX returns 0.
;Otherwise, DeleteObject should be used to delete the handle returned in EAX when done using it.
;
;-----------------------------------------
LOCAL bms :BITMAP
LOCAL hdcDesktop :HDC
LOCAL hdcTemp1 :HDC
LOCAL hdcTemp2 :HDC
LOCAL hbmpPrev1 :HBITMAP
LOCAL hbmpOutput :HBITMAP
LOCAL hbmpPrev2 :HBITMAP
;-------------------------
INVOKE GetObject,hbmpInput,sizeof BITMAP,addr bms
.if eax
INVOKE GetDC,HWND_DESKTOP
mov hdcDesktop,eax
INVOKE CreateCompatibleDC,eax
mov hdcTemp1,eax
INVOKE SelectObject,eax,hbmpInput
mov hbmpPrev1,eax
INVOKE CreateCompatibleDC,hdcDesktop
mov hdcTemp2,eax
INVOKE CreateCompatibleBitmap,hdcDesktop,bms.bmWidth,bms.bmHeight
mov hbmpOutput,eax
INVOKE SelectObject,hdcTemp2,eax
mov hbmpPrev2,eax
mov ecx,bms.bmHeight
xor edx,edx
mov eax,ecx
neg ecx
dec eax
INVOKE StretchBlt,hdcTemp2,edx,eax,bms.bmWidth,ecx,
hdcTemp1,edx,edx,bms.bmWidth,bms.bmHeight,SRCCOPY
INVOKE SelectObject,hdcTemp2,hbmpPrev2
INVOKE DeleteDC,hdcTemp2
INVOKE SelectObject,hdcTemp1,hbmpPrev1
INVOKE DeleteDC,hdcTemp1
INVOKE ReleaseDC,HWND_DESKTOP,hdcDesktop
mov eax,hbmpOutput
.endif
ret
VertFlip ENDP
;**************************************************************************************************
EDIT - made a small change and tested it :U
Now I know this will make me look dense but I am having a Brain fart moment .... :(what am I doing wrong this will not work for me ....
I need to be able to flip the images right after I load them but use my own method of painting them
Thank you for all your help
well - you load the BMP, as usual
save the handle
then, you call the function - whichever one you use - i think qWord's has a slight bug :P
those functions return a new BMP handle
save that handle, also
mov hIMG,eax
invoke VertFlip,hIMG
mov hIMGflipped,eax ;<-------------------------------VertFlip returns a new handle
invoke CreatePatternBrush,hIMG
if you do not need both handles, flip the resource image - lol (DOH!) (http://thmg.photobucket.com/albums/v166/cybercat6/Zero/th_homer_doh.gif)
there is no bug - my functions and hfheatherfox07's last example (using my func.) works as excepted.
invoke StretchBlt,hMemDC1,0,bmp.bmHeight,bmp.bmWidth,edx,...
the last line number is [bmp.bmHeight] - 1
:P
you've got me :P
Quote from: qWord on May 13, 2012, 07:35:26 PM
you've got me :P
that doesn't happen very often - i better put it in a frame :bg
Quote from: dedndave on May 13, 2012, 07:18:15 PM
mov hIMG,eax
invoke VertFlip,hIMG
mov hIMGflipped,eax ;<-------------------------------VertFlip returns a new handle
invoke CreatePatternBrush,hIMG
I told you I had a brain fart day LOL :lol
but Why Am I still using the old "hIMG" handle when CreatePatternBrush and not the new handle "hIMGflipped"
Quote from: dedndave on May 13, 2012, 07:20:16 PM
if you do not need both handles, flip the resource image - lol (DOH!) (http://thmg.photobucket.com/albums/v166/cybercat6/Zero/th_homer_doh.gif)
I am working on the Areo Glass Skin and I was going to ad it to that thread ... I wanted a way that people could download that and use their own buttons ...
I agree flipping the resources is the way to go but you need to purchase a good Photoshop software if you want to use other buttons ...this way people could just downland the Areo Glass "template" and use a a free tool like http://www.portablefreeware.com/download.php?id=775 to screen capture tool an image to use
oh - so you are only going to use the flipped handle...
in that case, use DeleteObject to get rid of the original handle as soon as it is flipped
and use the flipped handle to draw