News:

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

how to cut a bitmap?

Started by RHL, April 12, 2012, 05:03:57 AM

Previous topic - Next topic

Gunner

@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.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

hfheatherfox07

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

qWord

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
FPU in a trice: SmplMath
It's that simple!

fearless

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.
ƒearless

hfheatherfox07

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

dedndave

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

qWord

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.
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

Oh I need to do a vertical LOL  and get the handle for each part

qWord

; 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
FPU in a trice: SmplMath
It's that simple!

hfheatherfox07

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