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

RHL

Hello guys... me again :P
I want know how "cut" a bitmap...

for example i have this image:


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

qWord

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

SteveAsm

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

RHL

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

qWord

see attachment

qWord
FPU in a trice: SmplMath
It's that simple!

RHL

well, thanks but I do not know how to use the extensions
I'm just learning x86 :P

dedndave

what extensions ?
that is x86   :P

RHL

but is different no? :P
I do not understand :(

dedndave

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

RHL

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

hfheatherfox07

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

hfheatherfox07

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

jj2007

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 ::)

Shantanu Gadgil

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
To ret is human, to jmp divine!

dedndave

also, NotePad++ has more damn features than i can use in a life-time   :lol
http://notepad-plus-plus.org/