|
-
Feb 20th, 2001, 10:41 PM
#1
Thread Starter
Fanatic Member
OK here is a function I've written to create a mask of any image that is currently stored in a Device Context and it works wonderfully besides being slow as hell....
Code:
Public Sub MaskTo(ByVal phDC As Long, pTranspColor As Long)
Dim lX As Long, lY As Long
For lX = 0 To lngWdth
For lY = 0 To lngHgt
If GetPixel(lngDC, lX, lY) = pTranspColor Then
SetPixelV phDC, lX, lY, vbBlack
Else
SetPixelV phDC, lX, lY, vbWhite
End If
Next lY
Next lX
End Sub
What I'm wondering is if there is a better way of doing this as this method is slow and tedious, it seems I've seen this done a more efficient ways but I cannot seem to find the examples anywhere, so if anybody can get me on the right track it would be much appreciated. Thanks in advance!
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 20th, 2001, 10:46 PM
#2
Frenzied Member
Ouch, all those Get & SetPixels! It's painful just seeing them... can't you get an array of RGB values or something?
Harry.
"From one thing, know ten thousand things."
-
Feb 20th, 2001, 11:00 PM
#3
Thread Starter
Fanatic Member
Not quite sure what that would accomplish HarryW, can you elaborate a lil' bit?
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 20th, 2001, 11:19 PM
#4
Frenzied Member
Well I mean it would be much much quicker if you could deal with the image as an array of RGB values, instead of GetPixel and SetPixel all the time. I only use DirecDraw for graphics stuff, and I also only really use C++, so I'm used to having everything in memory and... well.... quicker
Harry.
"From one thing, know ten thousand things."
-
Feb 20th, 2001, 11:25 PM
#5
Thread Starter
Fanatic Member
Well essentially this MaskTo function should only be called once and draws a mask to a seperate DC offscreen and then all the Blting stuff is done to make the image transparent, so in other words it would seem like a waste of memory to store the entire image as an array of pixels when this array should only be accessed once per image. I'm probably just being too picky but 8 - 10 seconds to make a mask of each image just seems like to much too me.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|