The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: RHL on April 12, 2012, 05:03:57 AM

Title: how to cut a bitmap?
Post by: RHL on April 12, 2012, 05:03:57 AM
Hello guys... me again :P
I want know how "cut" a bitmap...

for example i have this image:
(http://img824.imageshack.us/img824/2056/mybitmap.png)

I know use the bitblt function but I want "cut" 64x64 and store the handle in a DWORD variable for use later...
but i do know not how do it... please, could tell me which function API should use.

hey thnaks u very much in advance
Title: Re: how to cut a bitmap?
Post by: qWord on April 12, 2012, 11:27:05 AM
1. create two compatible DCs: SrcDC and DestDC
2. create or load source-bitmap and select it in SrcDC
3. create a compatible bitmap (64x64) and select it in DestDC
4. Copy (BitBlt) the corresponding region from the SrcDC to DestDC.
5. goto to 3 until all sub-bitmaps are copied.

Common lifetime of GDI objects:
(0. create DC)
1. create object
2. hOrgObj= SelectObject(DC,object)
3. do stuff with DC
4. DeleteObject(SelectObject(DC,hOrgObj))
(5. delete DC)
Title: Re: how to cut a bitmap?
Post by: SteveAsm on April 12, 2012, 02:59:43 PM
Do you have a copy of the platform SDK ?
If so, search for GDI functions: BITMAPS.

If not, here is a link:
http://msdn.microsoft.com/en-us/library/dd183385(v=vs.85).aspx
Title: Re: how to cut a bitmap?
Post by: RHL on April 12, 2012, 08:19:22 PM
thanks Word, I tried with this:


mov eax,uMsg
.if eax==WM_INITDIALOG
invoke GetDlgItem,hWin,1001
mov hstatic,eax ; get handle to static control

invoke GetDC,hstatic ; get hanlde device context
mov hDC,eax

invoke CreateCompatibleDC,hDC
mov srcDC,eax

invoke CreateCompatibleDC,hDC
mov desDC,eax

invoke LoadBitmap,hInstance,123       ; 123 = bitmap ID
mov hbitmap,eax

invoke SelectObject,srcDC,hbitmap
invoke BitBlt,desDC,32,32,0,0,srcDC,0,0,SRCCOPY

invoke DeleteObject,desDC ; is right?
invoke DeleteObject,srcDC ; is right?
invoke DeleteDC,hDC ; is right?


I have one static control ( final destiny ), and created two HDC ( src ad destiny ) but i do not work, What do I failed?

@SteveAsm:

yeah, I looked the SDK examples but, they are complex :S
Title: Re: how to cut a bitmap?
Post by: qWord on April 12, 2012, 09:41:24 PM
see attachment

qWord
Title: Re: how to cut a bitmap?
Post by: RHL on April 13, 2012, 12:16:51 AM
well, thanks but I do not know how to use the extensions
I'm just learning x86 :P
Title: Re: how to cut a bitmap?
Post by: dedndave on April 13, 2012, 12:23:36 AM
what extensions ?
that is x86   :P
Title: Re: how to cut a bitmap?
Post by: RHL on April 13, 2012, 12:37:07 AM
but is different no? :P
I do not understand :(
Title: Re: how to cut a bitmap?
Post by: dedndave on April 13, 2012, 12:50:04 AM
qWord always writes good code   :U

he is using a lot of macros, indentation, and if/else/endif/while/endw structures
i hate that stuff - but - even i can read his code   :P

look up the "rv" and "fn" macros
they are in \masm32\macros\macros.asm
and they are described in \masm32\help\hlhelp.chm

it might help to disassemble the program
then, follow the disassembled code while reading the source

here is the disassembly file...
Title: Re: how to cut a bitmap?
Post by: RHL on April 13, 2012, 12:59:05 AM
ok, good idea :) thanks dedndave u always help me, thanks a lot
also thanks qWord.

one thing... this code "cut" the bitmap?  I looked that only draws the bitmap : P


EDIT:
dis extension... haha guys why they put rare things ( for me ) :( haha - ok I have to investiger :P
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 13, 2012, 10:59:26 PM
Quote from: RHL on April 13, 2012, 12:59:05 AM


EDIT:
dis extension... haha guys why they put rare things ( for me ) :( haha - ok I have to investiger :P

LOL

Drag it over notepad   :wink
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 13, 2012, 11:16:30 PM
I prefer to use Notepad2 by Florian ..... It recognizes most assembly Formats  :U

P.S

you could Also recode documents and asm's that are in other languages and than use Google translate to translate them  :wink
Title: Re: how to cut a bitmap?
Post by: jj2007 on April 14, 2012, 06:07:53 AM
Quote from: hfheatherfox07 on April 13, 2012, 11:16:30 PM
you could Also recode documents and asm's that are in other languages and than use Google translate to translate them  :wink

Good idea :U I have a 700k Basic source, will see if Google translate can port it to Masm :toothy

Notepad2 looks ok, but I am always surprised how different views are what constitutes a good editor. For example, my recent files list has 20 entries - N2 does not even have one; and no bookmarks, and apparently (?) no F1 that opens to Win32.hlp etc... on the other hands, it has settings for long lines, and the wndow title display can be configured ::)
Title: Re: how to cut a bitmap?
Post by: Shantanu Gadgil on April 14, 2012, 01:45:55 PM
Quote from: jj2007 on April 14, 2012, 06:07:53 AM
Notepad2 looks ok, but I am always surprised how different views are what constitutes a good editor. For example, my recent files list has 20 entries - N2 does not even have one; and no bookmarks, and apparently (?) no F1 that opens to Win32.hlp etc... on the other hands, it has settings for long lines, and the wndow title display can be configured ::)

Sorry to digress from the main topic but ...

You have to enable the setting in Notepad2 to save recent files; Settings > Remember Recent Files.

On another note, from personal experience I would like to suggest the following:
* Notepad2 as notepad replacement (extremely light-weight. It would not be really suitable for the F1 > win32hlp thing that you are looking for)
* Programmers Notepad 2 (pnotepad.org) (This is more what you might be looking for)
* HxD for the occasional hex editing that you might need!  :green2

Regards,
Shantanu
Title: Re: how to cut a bitmap?
Post by: dedndave on April 14, 2012, 01:54:00 PM
also, NotePad++ has more damn features than i can use in a life-time   :lol
http://notepad-plus-plus.org/
Title: Re: how to cut a bitmap?
Post by: dedndave on April 14, 2012, 01:57:16 PM
Quote from: jj2007 on April 14, 2012, 06:07:53 AM
Quote from: hfheatherfox07 on April 13, 2012, 11:16:30 PM
you could Also recode documents and asm's that are in other languages and than use Google translate to translate them  :wink

Good idea :U I have a 700k Basic source, will see if Google translate can port it to Masm :toothy

Notepad2 looks ok, but I am always surprised how different views are what constitutes a good editor. For example, my recent files list has 20 entries - N2 does not even have one; and no bookmarks, and apparently (?) no F1 that opens to Win32.hlp etc... on the other hands, it has settings for long lines, and the wndow title display can be configured ::)

google translate will waste no time in telling you that it's too big   :P
Title: Re: how to cut a bitmap?
Post by: jj2007 on April 14, 2012, 05:13:18 PM
Quote from: Shantanu Gadgil on April 14, 2012, 01:45:55 PM
You have to enable the setting in Notepad2 to save recent files; Settings > Remember Recent Files.
Greyed out in the version that was attached above.

Quote
* Notepad2 as notepad replacement (extremely light-weight. It would not be really suitable for the F1 > win32hlp thing that you are looking for)

632k=12*RichMasm  (http://www.masm32.com/board/index.php?topic=9044.0)- the latter is really light-weight although it does include the F1 thing :bg
Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 02:22:49 AM
i have been playing with loading a transparent PNG strip and splitting it up   :P
not as easy as it should be - lol

anyways, it dawned on me that they don't need to be PNG's, nor split up

64x64 icons under XP....

(http://www.masm32.com/board/index.php?action=dlattach;topic=18686.0;id=10574)

let me owner-draw the last box, then i'll post some code   :bg
Title: Re: how to cut a bitmap?
Post by: RHL on April 15, 2012, 02:51:33 AM
 :clap:
thanks a lot dedndave, for teaching  :toothy
Title: Re: how to cut a bitmap?
Post by: RHL on April 15, 2012, 03:04:51 AM
dave, the file is damage :P

EDIT:  this is the png file right?  :]
Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 03:20:45 AM
it is a PNG file - save it, then remove the .ZIP extension by renaming the file   :P

Quotethanks a lot dedndave, for teaching
i am learning, too   :U

ok
i am not getting what i want out of the owner-draw thing   :(
during WM_INITDIALOG...
            INVOKE  GetDlgItem,hWnd,IDC_STC5 ;ebx
            mov     hStatic5,eax
            INVOKE  CreateSolidBrush,000000FFh          ;COLORREF = red
            mov     hBrush5, eax


then, during WM_DRAWITEM...
        mov     edx,lParam
            .if [edx].DRAWITEMSTRUCT.CtlID==IDC_STC5
                .if [edx].DRAWITEMSTRUCT.itemAction==ODA_DRAWENTIRE

                    ;draw stuff here
                    INVOKE  SelectObject,[edx].DRAWITEMSTRUCT.hdc,hBrush5

                .endif
            .endif

i will figure it out, tomorrow   :P

in the mean time, i know you want to play, so i'll post what i have...
(this is a real ZIP file)
Title: Re: how to cut a bitmap?
Post by: RHL on April 15, 2012, 03:47:18 AM
dave a question :D
always I like the way your programmed, I want mean, only the asm file, if depends exist also ( you do not use a IDE ) use.. notepad...? wft? notepad... lol
and for assembled a .bat file :D you do it? or exist a program for make it?

I will learn to no depend to a IDE, i like :D
Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 03:54:14 AM
well - i should have a little program to set up my projects, huh   :U
but - i use Notepad to edit the batch file - using Find/Replace   :P

the "if not exist" - i do that so if you are not in the right folder, it won't delete any files

as for IDE's...
i might learn to use Ketil's RadAsm and ResEd - it looks pretty nice   :U
for now, i am still learning windows - lol

i came from the days of DOS
batch files did a lot of our work for us, back then - if you knew how to write them
Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 12:07:57 PM
ok
if you just want a static control with a solid color (and text, perhaps)...
the easy way is to handle WM_CTLCOLORSTATIC

(http://www.masm32.com/board/index.php?action=dlattach;topic=18686.0;id=10577)

if you want to paint something more, we will have to do owner-drawn
Title: Re: how to cut a bitmap?
Post by: fearless on April 15, 2012, 09:46:08 PM
Hi,

Ive been looking through this code and other examples and trying to load part of bitmap image onto a static control so that i can use scroll bars to move up, down, left or right and view the bitmap inside this little viewport. Does anyone have any examples of this, i tried converting this example i found (http://www.codeproject.com/Articles/3175/Displaying-Bitmap-with-Scrolling) to asm but didnt get any success.

The code i do have is a complete mess, from trying various things, copy and pasting other code from other examples and trying out things, but without any success. Here is some of it, might help someone to do a proper conversion or point out where ive gone wrong. Thanks

LoadWorldMapBMP PROC
    LOCAL rectStaticClient:RECT
    LOCAL horz:SCROLLINFO
    LOCAL vert:SCROLLINFO

; This basic example works, but image overflows the static control size, need to 'bound' it to our defined viewport (static control) size.
; Invoke LoadImage, NULL, Addr szWorldMapBMP, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
; mov hWorldMapBmp, eax
; .IF eax != NULL
;     Invoke SendDlgItemMessage, hWin, IDC_WORLDMAP, STM_SETIMAGE, IMAGE_BITMAP, hWorldMapBmp
; .ENDIF

    mov offsetx, 0
    mov offsety, 0
    mov sourcex, 0
    mov sourcey, 0
   
    Invoke LoadImage, NULL, Addr szWorldMapBMP, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE
    mov m_hBmpNew, eax
    .IF m_hBmpNew == NULL
        PrintText 'Load Image Failed'
        mov eax, FALSE
        ret
    .ELSE
        Invoke GetClientRect, m_hBmpNew, Addr rectStaticClient
       
        mov eax, rectStaticClient.left
        mov m_size.x, eax
        mov eax, rectStaticClient.top
        mov m_size.y, eax
       
        Invoke ClientToScreen, m_hBmpNew, Addr m_size
        Invoke ScreenToClient, m_hBmpNew, Addr m_size
       
        mov eax, rectStaticClient.left
        mov m_pt.x, eax
        mov eax, rectStaticClient.top
        mov m_pt.y, eax
        Invoke GetObject, m_hBmpNew, SIZEOF BITMAP, Addr m_bmInfo
        Invoke SelectObject, m_dcMem, m_hBmpNew
        mov m_hBmpOld, eax
       
    .ENDIF     
   
    mov eax, m_pt.x
    mov offsetx, eax
    mov eax, m_pt.y
    mov offsety, eax
   
    mov eax, offsetx
    add eax, m_size.x
    Invoke MoveWindow, hVSCROLL, eax, offsety, 18, m_size.y, TRUE
   
    mov eax, offsety
    add eax, m_size.y
    Invoke MoveWindow, hHSCROLL, offsetx, eax, m_size.x, 18, TRUE
   
    mov horz.cbSize, SIZEOF SCROLLINFO
    mov horz.fMask, SIF_ALL
    mov horz.nMin, 0
    mov eax, m_bmInfo.bmWidth
    mov ebx, m_size.x
    sub ebx, eax
    mov horz.nMax, eax
    mov horz.nPage, 0
    mov horz.nPos, 0
    mov horz.nTrackPos, 0
   
    mov ebx, m_bmInfo.bmWidth
    .IF ebx <= m_size.x
        mov eax, m_size.x
        sub eax, ebx
        .IF eax == 0
            mov eax, m_pt.x
            mov offsetx, eax
        .ELSE
            xor edx, edx
            mov ecx, 2
            div ecx
            mov ebx, m_pt.x
            add eax, ebx
            mov offsetx, eax   
        .ENDIF       
        mov ebx, m_bmInfo.bmWidth
        add eax, ebx
        Invoke MoveWindow, hVSCROLL, eax, offsety, 18, m_size.y, TRUE
        Invoke ShowWindow, hHSCROLL, SW_HIDE
    .ELSE
        Invoke ShowWindow, hHSCROLL, SW_SHOW
    .ENDIF
    Invoke SetScrollInfo, hHSCROLL, SB_CTL, Addr horz, TRUE
   
   
    mov vert.cbSize, SIZEOF SCROLLINFO
    mov vert.fMask, SIF_ALL
    mov vert.nMin, 0
    mov eax, m_bmInfo.bmHeight
    mov ebx, m_size.y
    sub ebx, eax
    mov vert.nMax, eax
    mov vert.nPage, 0
    mov vert.nPos, 0
    mov vert.nTrackPos, 0   
   
    mov ebx, m_bmInfo.bmHeight
    .IF ebx <= m_size.y
        mov eax, m_size.y
        sub eax, ebx
        .IF eax == 0
            mov eax, m_pt.y
            mov offsety, eax
        .ELSE
            xor edx, edx
            mov ecx, 2
            div ecx
            mov ebx, m_pt.x
            add eax, ebx
            mov offsety, eax   
        .ENDIF       
        mov ebx, m_bmInfo.bmHeight
        add eax, ebx
        Invoke MoveWindow, hHSCROLL, offsetx, eax, m_size.x, 18, TRUE
        Invoke ShowWindow, hVSCROLL, SW_HIDE
    .ELSE
        Invoke ShowWindow, hVSCROLL, SW_SHOW
    .ENDIF
    Invoke SetScrollInfo, hVSCROLL, SB_CTL, Addr vert, TRUE
   
    Invoke InvalidateRect, m_hBmpNew, Addr rectStaticClient, TRUE
    ret

LoadWorldMapBMP endp


Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 10:07:45 PM
i have never tried scrollbars inside a static   :P
no need for it to be a static, either, i suppose - it could just be a window
let me play with what you have....

off hand, the advantage of using a static is that it would size itself to the bitmap
that doesn't seem desirable, in this case
Title: Re: how to cut a bitmap?
Post by: fearless on April 15, 2012, 10:24:13 PM
Hi Dave,

My original plan was to allow for a map editor of sorts for baldurs gate games. If the main map is say a bmp and is easily loaded, i wanted an interface that allowed scrolling around the full extent of the bitmap within the window (or static control as i tried) but any solution that achieves the same result would be ace.

Once id got that far (which i havent :D) i thought i could create little static controls ontop of the map which would be points of interest, destinations or whatever. These could be clicked on to give properties that could be edited (in another side window or something like) and would show position (x, y on the map), name and other details and id also thought i could move these statics around as well (updating the internal files reference values for these places) with some sort of mousemove override. I thought to do a simple STM_SETIMAGE for these little map markers, could be little icons, or red squares or anything tbh that would allow an easy way to manipulate these items for the end user.

Anyhows, it looks like it was more difficult than i first thought. The basic load bmp and scroll it around has me stumped so far, let alone the other stuff. I suppose that putting the image in its own window with its own scrollbars allows the system to control the scrolling, so that might be a better solution and i could create a seperate window for the 'properties' thing later on.

Any ideas/solutions or whatever stuff you can come up would be great.
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 15, 2012, 10:38:21 PM
Quote from: qWord on April 12, 2012, 09:41:24 PM
see attachment

qWord

Hi I saw this thread and I remembered something that I was trying to do a while back ... http://www.masm32.com/board/index.php?PHPSESSID=bbc80810adc7b9ae86e1d81de57aa675&topic=17303.msg145116#msg145116

I was trying to cut a bitmap so I can load it and scroll it ...is it possible to define each image in the data section?
Title: Re: how to cut a bitmap?
Post by: dedndave on April 15, 2012, 10:40:24 PM
i will play with it over the next few days
as for the little "markers", you could just make them buttons   :P
only place the ones that are in full view
hide the others, or perhaps, create/destroy them as needed

i have some code that i use for scrolling a window that holds text
i use the same code for horz and vert scrolling
and - i have mousewheel code that works similarly

i have a couple questions...

what size is this little window (either with or without the scrollbars) ?
how big is the overall map bitmap ?
is the window sizable ?

i have never tried using my scroll code for an image - might be a fun project
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 15, 2012, 10:41:58 PM
there is an example in the last post on my thread .... http://cyberdoomsystems.narod.ru/ripp/about.rar

I am still working on that enumerate windows app.....almost there  ::)
Title: Re: how to cut a bitmap?
Post by: Gunner on April 15, 2012, 10:43:35 PM
@hfheatherfox07, in the MASM32 directory there is a program called fda2 (if you don't have it, search the board), it will allow you to "embed" anything in the data section, you just then use something like BitmapFromMemory from the MASM Library.

@Dave and the OP, there is some source on the board that shows how to create a scrollable viewport (a plain window that scorlls), I will look for the source.

First one uses a dialog, the second one uses a "normal" window.  I have used code from the second one, and it is not hard to use or modify.
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 15, 2012, 10:55:50 PM
That is not what will do it the fda will make a whole image into data but not cut a strip ...I don't think

you mean this here http://www.masm32.com/board/index.php?topic=937.0

I want to cut the bitmap strip and have each individual image In the data section so for example :


szScrollText  db 'Welcome to MASM32, state of the art Windows assembler programming.',0Dh,0Ah
            db 0Dh,0Ah ; puts a space !
            db 0Dh,0Ah
            db   "Image1"
            db 'Many remember assembler as a complex and tedious necessity when a high level',0Dh,0Ah
            db   "Image2"
            db 'language failed to deliver in terms of capacity or performance yet it has always ',0Dh,0Ah
            db   "Image3"
            db 'been capable of writing full size applications in elegant and efficient ways.',0Dh,0Ah
            db 'MASM has the capacity to write proper modular code which becomes a necessity as',0Dh,0Ah



So I can scroll the text and image together
Title: Re: how to cut a bitmap?
Post by: qWord on April 15, 2012, 11:03:50 PM
Quote from: hfheatherfox07 on April 15, 2012, 10:55:50 PM
szScrollText  db 'Welcome to MASM32, state of the art Windows assembler programming.',0Dh,0Ah
            db 0Dh,0Ah ; puts a space !
            db 0Dh,0Ah
            db   "Image1"
            db 'Many remember assembler as a complex and tedious necessity when a high level',0Dh,0Ah
            db   "Image2"
            db 'language failed to deliver in terms of capacity or performance yet it has always ',0Dh,0Ah
            db   "Image3"
            db 'been capable of writing full size applications in elegant and efficient ways.',0Dh,0Ah
            db 'MASM has the capacity to write proper modular code which becomes a necessity as',0Dh,0Ah



So I can scroll the text and image together
you may try it with HTML  :lol
Title: Re: how to cut a bitmap?
Post by: fearless on April 16, 2012, 12:00:47 AM
Been playing with painting the image directly onto the window as per this thread (http://www.masm32.com/board/index.php?topic=18534.0)

Image size could be larger than the window, perhaps even larger than the monitor resolution. So i felt that i could create a small viewport to scroll about the bitmap in case it was large.  So i suppose it could be variable, but the window to hold it could be set to a particular size. I have dummied up a quick idea of what i was planning in the attached image (mapeditor.jpg.zip - just rename to .jpg). But im happy if a solution is a child window inside a main window to do something similar.

I have some code in a radasm project (without the original bmp - its 3MB) which is attached as well, but i havnt got round to the scrolling part yet.
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 27, 2012, 08:47:21 PM
Quote from: qWord on April 12, 2012, 09:41:24 PM
see attachment

qWord


How do calculate to weather the bitmap is horizontal or vertical ?
I want to cut this
Title: Re: how to cut a bitmap?
Post by: dedndave on April 27, 2012, 08:51:49 PM
after you load the image (LoadImage, LoadBitmap), you can use GetObject to get the dimensions
is that what you mean ?

        LOCAL   bms:BITMAP

        INVOKE  GetObject,hbmpImage,sizeof BITMAP,addr bms
        mov     ecx,bms.bmWidth
        mov     eax,bms.bmHeight
Title: Re: how to cut a bitmap?
Post by: qWord on April 27, 2012, 08:56:14 PM
Quote from: hfheatherfox07 on April 27, 2012, 08:47:21 PMHow do calculate to weather the bitmap is horizontal or vertical ?
you can't calculate this information - you must feed this information somehow into your program.
The function SplitHorz() from my example assumes that you are passing a horizontal strip of N images.
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 27, 2012, 08:58:06 PM
Oh I need to do a vertical LOL  and get the handle for each part
Title: Re: how to cut a bitmap?
Post by: qWord on April 27, 2012, 09:03:13 PM
; input:  hBitmap = image-strip
;         ny = height of sub-image
; return: eax = pointer to handle array (use hfree-macro for deletion)
;               or zero, if fail.
;         ecx = number of handels
;         LOWORD(edx) = bitmap width , HIGHWORD(edx) = bitmap height
SplitVert proc uses edi esi ebx hBitmap:HBITMAP,ny:DWORD
LOCAL bmp:BITMAP
LOCAL hDC:HDC
LOCAL hSrcDC:HDC
LOCAL hDestDC:HDC
LOCAL hBmpOrg1:HANDLE
LOCAL hBmpOrg2:HANDLE
LOCAL n:DWORD

;/* get bitmap width and height */
.if rv(GetObject,hBitmap,SIZEOF bmp,ADDR bmp)

;/* calcualte number of sub-images */
xor edx,edx
mov eax,bmp.bmHeight
mov ecx,ny
div ecx
.if eax
mov n,eax
lea eax,[eax*4]
mov edi,halloc(eax) ; allocate handle-array

;/* create DCs */
mov hDC,rv(GetDC,rv(GetDesktopWindow)) ; reference-DC
mov hSrcDC,rv(CreateCompatibleDC,hDC)
mov hDestDC,rv(CreateCompatibleDC,hDC)

;/* select bitmap and save privious */
mov hBmpOrg1,rv(SelectObject,hSrcDC,hBitmap)

xor esi,esi
xor ebx,ebx
.while esi < n
;/* create bitmap and select it into DC. Also save privious handle */
mov hBmpOrg2,rv(SelectObject,hDestDC,rv(CreateCompatibleBitmap,hDC,bmp.bmWidth,ny))

;/* copy image */
invoke BitBlt,hDestDC,0,0,bmp.bmWidth,ny,hSrcDC,0,ebx,SRCCOPY

;/* reload orginal bitmap and save the returned one */
mov [edi+esi*4],rv(SelectObject,hDestDC,hBmpOrg2)

add esi,1
add ebx,ny
.endw

invoke ReleaseDC,rv(GetDesktopWindow),hDC

;/* restore orginal bitmaps and delete the created one */
invoke DeleteObject,rv(SelectObject,hSrcDC,hBmpOrg1)

;/* delete DCs */
invoke DeleteDC,hSrcDC
invoke DeleteDC,hDestDC

mov eax,edi
mov ecx,bmp.bmHeight
mov edx,bmp.bmHeight
shl edx,16
mov dx,cx
mov ecx,n
.endif
.endif
ret

SplitVert endp
Title: Re: how to cut a bitmap?
Post by: hfheatherfox07 on April 28, 2012, 08:04:07 PM
I don't get it .... I took the first example that you had and change the WHITE_BRUSH to BLACK_BRUSH and it looks like the bitmap strip is not being cut ....what I wanted to do way to see only the button with the "Glow" no background !
SO I can use it for buttons ...but I really do not get your code ...how do I get the handle for each of the images ....?
Like himage1,himage2,himage3 if for example the strip has three images .....
I included an Windows 7 Areo button example that I made .... that is what I want the buttons for