Image Masks...
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
Image Masks...
Im playing around with the toolbar pro LIB, and im trying to figure out how to create a "mask" from a strip in a bitmap. the bitmap is made up of icons pasted into photoshop, but i have no idea of how to get the mask like in the examples of the toolbar pro lib. any ideas?
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
All I've done in the past is make a copy of the image strip, load it into MS Paint and fill the background white. With the icons themselves, I just replace all regions coloured white, with black and leave the rest. It seems to work okay.
If you haven't come across the following, it comes well recommended:
http://www.snapfiles.com/get/toolbarpaint.html
If you haven't come across the following, it comes well recommended:
http://www.snapfiles.com/get/toolbarpaint.html
I may look like a mule, but I'm not a complete ass.
-
localmotion34
- Enthusiast

- Posts: 665
- Joined: Fri Sep 12, 2003 10:40 pm
- Location: Tallahassee, Florida
huh? that still leaves me with no clue as to HOW you did it?
Code: Select all
!.WHILE status != dwPassedOut
! Invoke AllocateDrink, dwBeerAmount
!MOV Mug, Beer
!Invoke Drink, Mug, dwBeerAmount
!.endw
Readup on how to use the selection tool and the magic wand tool in photoshop. You just need to select all the areas that you don't want to appear in the buttons and turn them to white. All the areas you do want to appear in buttons turn to black. easy.
1. select all the backgrounds using select tool or magic wand
2. turn the selection to white
3. invert the selection (menu command)
4. turn to black.
5. Save as 'mask.bmp'.
1. select all the backgrounds using select tool or magic wand
2. turn the selection to white
3. invert the selection (menu command)
4. turn to black.
5. Save as 'mask.bmp'.
I just hacked up the following which will create a basic mask from a given bitmap.
It's not very sophisticated and there's not much error checking, but it seems to work.
Code: Select all
;This small program takes an image in .bmp format and generates a correspomding mask
;suitable for Danilo's TOOLBAR pro etc.
;The mask is saved with 'Mask.bmp' appended to the name.
;By srod.
;Purebasic 4.
Enumeration ;images
#bmap
EndEnumeration
Define pt.POINT, file$, hBmap, hMaskBmp, bmapdc, maskdc, transcolour
pt\x=0 : pt\y=0 ;This means that the colour of the point(0, 0) in the selected image will
;be taken to be the transparent background etc. This will appear as white in the mask.
;Change as appropriate.
;Alternatively, change the value of the variable 'transcolour' below to an appropriate
;colour value.
;Open a file requester in order to select an image.
file$=OpenFileRequester("Select bitmap image...", GetCurrentDirectory(), "Bitmap | *.bmp",0)
If FileSize(file$)>0
hBmap=LoadImage(#bmap,file$)
bmapdc=StartDrawing(ImageOutput(#bmap))
;Set background colour (see above comment).
transcolour=Point(pt\x,pt\y)
;Now create the mask which ends up back in our original image.
maskDC = CreateCompatibleDC_(bmapdc)
hMaskBmp = CreateBitmap_(ImageWidth(#bmap), ImageHeight(#bmap), 1, 1, 0)
SelectObject_(maskdc, hMaskBmp)
SetBkColor_(bmapdc, transcolour)
BitBlt_(maskdc, 0, 0, ImageWidth(#bmap), ImageHeight(#bmap), bmapdc, 0, 0, #SRCCOPY)
SetBkColor_(bmapdc, #White)
BitBlt_(bmapdc, 0, 0, ImageWidth(#bmap), ImageHeight(#bmap), maskdc, 0, 0, #SRCCOPY)
StopDrawing()
;Tidy up.
DeleteDC_(maskDC)
DeleteObject_(hMaskBmp)
;Now save the mask image.
file$=ReplaceString(file$,".bmp","Mask.bmp")
SaveImage(#bmap,file$)
EndIf
I may look like a mule, but I'm not a complete ass.

