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

dedndave

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

jj2007

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 - the latter is really light-weight although it does include the F1 thing :bg

dedndave

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



let me owner-draw the last box, then i'll post some code   :bg

RHL

 :clap:
thanks a lot dedndave, for teaching  :toothy

RHL

dave, the file is damage :P

EDIT:  this is the png file right?  :]

dedndave

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)

RHL

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

dedndave

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

dedndave

ok
if you just want a static control with a solid color (and text, perhaps)...
the easy way is to handle WM_CTLCOLORSTATIC



if you want to paint something more, we will have to do owner-drawn

fearless

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


ƒearless

dedndave

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

fearless

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

hfheatherfox07

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?

dedndave

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

hfheatherfox07

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