From: Mike Williams on
"Bee" <Bee(a)discussions.microsoft.com> wrote in message
news:F62FF0CE-5501-4C16-A283-6A138CE34ACF(a)microsoft.com...

> Thanks Larry. Still fiddling.
> Ultimately I want to try to get the sprite alpha to
> work so I can get ghostly images.

I've realised by now that you don't really like posts with a lot of words in
them because you never actually seem to read them or respond to any
questions they may contain, so I'll cut to the quick and just post some code
for you. Create a new project for test purposes and place three PictureBoxes
and one Horizontal ScrollBar on the Form. Give the PictureBoxes the names
picBackground, picSprite and picTemp. Then paste in the following code.
There are lots of comments in the code, but they are not required reading
;-)

Mike

Option Explicit
Private Declare Function AlphaBlend Lib "msimg32.dll" _
(ByVal hdcDest As Long, _
ByVal xDest As Long, ByVal yDest As Long, _
ByVal WidthDest As Long, ByVal HeightDest As Long, _
ByVal hdcSrc As Long, _
ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal WidthSrc As Long, ByVal HeightSrc As Long, _
ByVal Blendfunc As Long) As Long
Private Declare Function TransparentBlt Lib "msimg32.dll" _
(ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
ByVal crTransparent As Long) As Boolean
Private Declare Function BitBlt Lib "gdi32" _
(ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, _
ByVal hSrcDC As Long, ByVal xSrc As Long, _
ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias _
"RtlMoveMemory" (Destination As Any, Source As Any, _
ByVal Length As Long)
Private Type BLENDFUNCTION
BlendOp As Byte
BlendFlags As Byte
SourceConstantAlpha As Byte
AlphaFormat As Byte
End Type
Private Const AC_SRC_OVER = &H0
Private translucency As Byte

Private Sub Form_Load()
Me.WindowState = vbMaximized
picBackground.ScaleMode = vbPixels
picBackground.AutoSize = True
picBackground.AutoRedraw = True
picBackground.Move 0, 0
picSprite.AutoRedraw = True
picSprite.ScaleMode = vbPixels
picSprite.AutoSize = True
picSprite.Visible = False
picTemp.AutoRedraw = True
picTemp.ScaleMode = vbPixels
picTemp.Visible = False
' load a main background picture at and display it
' at its full original image size for initial test
' purposes (regardless of whether it overflows the
' screen or not)
picBackground.Picture = LoadPicture("c:\temp\jessica2.jpg")
' load a sprite image (any small image will do,
' although something that looks like a typical
' sprite would be best). In this specific example when
' we actually draw it as a sprite we will use the colour
' of the pixel at its top left corner as the desired
' transparent colour (although you can instead use your
' own sprite and mask images if you wish - see notes in
' the DrawSpriteTranslucent routine below.
picSprite.Picture = LoadPicture("c:\temp\bear.bmp")
Set HScroll1.Container = picBackground
HScroll1.Min = 0
HScroll1.Max = 255
HScroll1.LargeChange = 50
HScroll1.Value = 128
HScroll1.Move 0, 0, 160, 28
HScroll1.TabStop = False
End Sub

Private Sub DrawSpriteTranslucent(X As Long, _
Y As Long, transClr As Long, translucency As Byte)
' Mike Williams (2010)
Dim BF1 As BLENDFUNCTION, lBF As Long
Dim wide As Long, high As Long
wide = picSprite.ScaleWidth
high = picSprite.ScaleHeight
picTemp.Width = picSprite.Width
picTemp.Height = picSprite.Height
' First grab a "sprite sized" rectangle of the
' existing background from the spot where we want
' to draw our sprite (so that the existing
' background at that position ends up in our
' temp PictureBox)
BitBlt picTemp.hdc, 0, 0, wide, high, _
picBackground.hdc, X, Y, vbSrcCopy
' Now perform a standard transparent blit of the
' sprite into temp PicBox over the top of the
' background stuff we just grabbed. In this example
' we are using the TransparentBlt API (which used
' to have a memory leak but is fine now in XP/Vista
' and later) and we are passing it the colour that
' we wish to be treated as transparent but you can
' instead use your own favourite method of
' transparently blitting a sprite using two separate
' blits of mask and image if you wish.
TransparentBlt picTemp.hdc, 0, 0, wide, high, _
picSprite.hdc, 0, 0, wide, high, transClr
' Now set up our blend to use the desired translucency
With BF1
.BlendOp = AC_SRC_OVER
.BlendFlags = 0
.SourceConstantAlpha = translucency
.AlphaFormat = 0
End With
CopyMemory lBF, BF1, 4
' The temp PicBox currently contains the appropriate
' portion of the main background image with the sprite
' transparently drawn on top of it, so we can now
' blend that composite image into the main background
' PicBox, which will result in only the "sprite"
' pixels being blended in because all other pixels
' in picTemp are the same as those already in the
' background PicBox, and any blend of two identical
' colour pixels results in the original colour
AlphaBlend picBackground.hdc, X, Y, wide, _
high, picTemp.hdc, 0, 0, _
wide, high, lBF
' Refresh the background PicBox so we can see the result
picBackground.Refresh
End Sub

Private Sub HScroll1_Change()
Me.Caption = "Translucency is currently " & Format _
(HScroll1.Value) & " (Use slider to change). " _
& " Click picture to draw sprite."
translucency = HScroll1.Value
End Sub

Private Sub HScroll1_Scroll()
Call HScroll1_Change
End Sub

Private Sub picBackground_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
' Alphablend the image in picSprite transparently
' onto our main picture (background) at the clicked
' location
Dim xp As Long, yp As Long, transColor As Long
' first adjust the coordinates of the click so that
' the centre of the sprite will end up at that position
xp = X - picSprite.ScaleWidth / 2 ' centre on clicked point
yp = Y - picSprite.ScaleHeight / 2 ' centre on clicked point
' now read the pixel in the top left corner of the sprite
' image and assume that to be the desired transparent
' colour
transColor = picSprite.Point(0, 0)
' draw the sprite onto the backgeound picture transparently
' with the non transparent sprite area blended in using the
' alpha translucency as determined by the position of the
' slider (this value is set in HScroll1 Change etc event)
DrawSpriteTranslucent xp, yp, transColor, translucency
End Sub


From: Bee on
Thank you Mike
It works but i don't yet understand it.
I need to study it for a while and hope my brain cells catch up soon.
Thanks again!
Sometimes questions do not make sense to me so I do not know how to answer.
This stuff is all so very new to me and a little overwhelming.
I need to let these new thoughts marinate.

"Mike Williams" wrote:

> "Bee" <Bee(a)discussions.microsoft.com> wrote in message
> news:F62FF0CE-5501-4C16-A283-6A138CE34ACF(a)microsoft.com...
>
> > Thanks Larry. Still fiddling.
> > Ultimately I want to try to get the sprite alpha to
> > work so I can get ghostly images.
>
> I've realised by now that you don't really like posts with a lot of words in
> them because you never actually seem to read them or respond to any
> questions they may contain, so I'll cut to the quick and just post some code
> for you. Create a new project for test purposes and place three PictureBoxes
> and one Horizontal ScrollBar on the Form. Give the PictureBoxes the names
> picBackground, picSprite and picTemp. Then paste in the following code.
> There are lots of comments in the code, but they are not required reading
> ;-)
>
> Mike
>
> Option Explicit
> Private Declare Function AlphaBlend Lib "msimg32.dll" _
> (ByVal hdcDest As Long, _
> ByVal xDest As Long, ByVal yDest As Long, _
> ByVal WidthDest As Long, ByVal HeightDest As Long, _
> ByVal hdcSrc As Long, _
> ByVal xSrc As Long, ByVal ySrc As Long, _
> ByVal WidthSrc As Long, ByVal HeightSrc As Long, _
> ByVal Blendfunc As Long) As Long
> Private Declare Function TransparentBlt Lib "msimg32.dll" _
> (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _
> ByVal nWidth As Long, ByVal nHeight As Long, _
> ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
> ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
> ByVal crTransparent As Long) As Boolean
> Private Declare Function BitBlt Lib "gdi32" _
> (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
> ByVal nWidth As Long, ByVal nHeight As Long, _
> ByVal hSrcDC As Long, ByVal xSrc As Long, _
> ByVal ySrc As Long, ByVal dwRop As Long) As Long
> Private Declare Sub CopyMemory Lib "kernel32" Alias _
> "RtlMoveMemory" (Destination As Any, Source As Any, _
> ByVal Length As Long)
> Private Type BLENDFUNCTION
> BlendOp As Byte
> BlendFlags As Byte
> SourceConstantAlpha As Byte
> AlphaFormat As Byte
> End Type
> Private Const AC_SRC_OVER = &H0
> Private translucency As Byte
>
> Private Sub Form_Load()
> Me.WindowState = vbMaximized
> picBackground.ScaleMode = vbPixels
> picBackground.AutoSize = True
> picBackground.AutoRedraw = True
> picBackground.Move 0, 0
> picSprite.AutoRedraw = True
> picSprite.ScaleMode = vbPixels
> picSprite.AutoSize = True
> picSprite.Visible = False
> picTemp.AutoRedraw = True
> picTemp.ScaleMode = vbPixels
> picTemp.Visible = False
> ' load a main background picture at and display it
> ' at its full original image size for initial test
> ' purposes (regardless of whether it overflows the
> ' screen or not)
> picBackground.Picture = LoadPicture("c:\temp\jessica2.jpg")
> ' load a sprite image (any small image will do,
> ' although something that looks like a typical
> ' sprite would be best). In this specific example when
> ' we actually draw it as a sprite we will use the colour
> ' of the pixel at its top left corner as the desired
> ' transparent colour (although you can instead use your
> ' own sprite and mask images if you wish - see notes in
> ' the DrawSpriteTranslucent routine below.
> picSprite.Picture = LoadPicture("c:\temp\bear.bmp")
> Set HScroll1.Container = picBackground
> HScroll1.Min = 0
> HScroll1.Max = 255
> HScroll1.LargeChange = 50
> HScroll1.Value = 128
> HScroll1.Move 0, 0, 160, 28
> HScroll1.TabStop = False
> End Sub
>
> Private Sub DrawSpriteTranslucent(X As Long, _
> Y As Long, transClr As Long, translucency As Byte)
> ' Mike Williams (2010)
> Dim BF1 As BLENDFUNCTION, lBF As Long
> Dim wide As Long, high As Long
> wide = picSprite.ScaleWidth
> high = picSprite.ScaleHeight
> picTemp.Width = picSprite.Width
> picTemp.Height = picSprite.Height
> ' First grab a "sprite sized" rectangle of the
> ' existing background from the spot where we want
> ' to draw our sprite (so that the existing
> ' background at that position ends up in our
> ' temp PictureBox)
> BitBlt picTemp.hdc, 0, 0, wide, high, _
> picBackground.hdc, X, Y, vbSrcCopy
> ' Now perform a standard transparent blit of the
> ' sprite into temp PicBox over the top of the
> ' background stuff we just grabbed. In this example
> ' we are using the TransparentBlt API (which used
> ' to have a memory leak but is fine now in XP/Vista
> ' and later) and we are passing it the colour that
> ' we wish to be treated as transparent but you can
> ' instead use your own favourite method of
> ' transparently blitting a sprite using two separate
> ' blits of mask and image if you wish.
> TransparentBlt picTemp.hdc, 0, 0, wide, high, _
> picSprite.hdc, 0, 0, wide, high, transClr
> ' Now set up our blend to use the desired translucency
> With BF1
> .BlendOp = AC_SRC_OVER
> .BlendFlags = 0
> .SourceConstantAlpha = translucency
> .AlphaFormat = 0
> End With
> CopyMemory lBF, BF1, 4
> ' The temp PicBox currently contains the appropriate
> ' portion of the main background image with the sprite
> ' transparently drawn on top of it, so we can now
> ' blend that composite image into the main background
> ' PicBox, which will result in only the "sprite"
> ' pixels being blended in because all other pixels
> ' in picTemp are the same as those already in the
> ' background PicBox, and any blend of two identical
> ' colour pixels results in the original colour
> AlphaBlend picBackground.hdc, X, Y, wide, _
> high, picTemp.hdc, 0, 0, _
> wide, high, lBF
> ' Refresh the background PicBox so we can see the result
> picBackground.Refresh
> End Sub
>
> Private Sub HScroll1_Change()
> Me.Caption = "Translucency is currently " & Format _
> (HScroll1.Value) & " (Use slider to change). " _
> & " Click picture to draw sprite."
> translucency = HScroll1.Value
> End Sub
>
> Private Sub HScroll1_Scroll()
> Call HScroll1_Change
> End Sub
>
> Private Sub picBackground_MouseDown(Button As Integer, _
> Shift As Integer, X As Single, Y As Single)
> ' Alphablend the image in picSprite transparently
> ' onto our main picture (background) at the clicked
> ' location
> Dim xp As Long, yp As Long, transColor As Long
> ' first adjust the coordinates of the click so that
> ' the centre of the sprite will end up at that position
> xp = X - picSprite.ScaleWidth / 2 ' centre on clicked point
> yp = Y - picSprite.ScaleHeight / 2 ' centre on clicked point
> ' now read the pixel in the top left corner of the sprite
> ' image and assume that to be the desired transparent
> ' colour
> transColor = picSprite.Point(0, 0)
> ' draw the sprite onto the backgeound picture transparently
> ' with the non transparent sprite area blended in using the
> ' alpha translucency as determined by the position of the
> ' slider (this value is set in HScroll1 Change etc event)
> DrawSpriteTranslucent xp, yp, transColor, translucency
> End Sub
>
>
> .
>
From: Bee on
Wow. Got it working. Added mousemove to position the sprite.
Now I see what you were talking about using your method to create the sprite.
Much better and more flexible.
This eliminates some code i was worried about.
Thanks again.
Now i need to size the sprite and add flip and rotate capability.
I have a very fast flip and rotate and now this is even easier not having to
deal with a mask and sprite.
Before I had problems with the mask and sprite being created exactly the same.
I was getting a few pixels hanging out now and then.
I think your way will eliminate that since I do not need a mask image now.
Where did you learn all of this or are you just a genius?
I find it very difficult to grasp these concepts. No graphics training at
all here.
Still learning. Using old gray matter. Taking my vitamins too.



"Mike Williams" wrote:

> "Bee" <Bee(a)discussions.microsoft.com> wrote in message
> news:F62FF0CE-5501-4C16-A283-6A138CE34ACF(a)microsoft.com...
>
> > Thanks Larry. Still fiddling.
> > Ultimately I want to try to get the sprite alpha to
> > work so I can get ghostly images.
>
> I've realised by now that you don't really like posts with a lot of words in
> them because you never actually seem to read them or respond to any
> questions they may contain, so I'll cut to the quick and just post some code
> for you. Create a new project for test purposes and place three PictureBoxes
> and one Horizontal ScrollBar on the Form. Give the PictureBoxes the names
> picBackground, picSprite and picTemp. Then paste in the following code.
> There are lots of comments in the code, but they are not required reading
> ;-)
>
> Mike
>
> Option Explicit
> Private Declare Function AlphaBlend Lib "msimg32.dll" _
> (ByVal hdcDest As Long, _
> ByVal xDest As Long, ByVal yDest As Long, _
> ByVal WidthDest As Long, ByVal HeightDest As Long, _
> ByVal hdcSrc As Long, _
> ByVal xSrc As Long, ByVal ySrc As Long, _
> ByVal WidthSrc As Long, ByVal HeightSrc As Long, _
> ByVal Blendfunc As Long) As Long
> Private Declare Function TransparentBlt Lib "msimg32.dll" _
> (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, _
> ByVal nWidth As Long, ByVal nHeight As Long, _
> ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, _
> ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, _
> ByVal crTransparent As Long) As Boolean
> Private Declare Function BitBlt Lib "gdi32" _
> (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, _
> ByVal nWidth As Long, ByVal nHeight As Long, _
> ByVal hSrcDC As Long, ByVal xSrc As Long, _
> ByVal ySrc As Long, ByVal dwRop As Long) As Long
> Private Declare Sub CopyMemory Lib "kernel32" Alias _
> "RtlMoveMemory" (Destination As Any, Source As Any, _
> ByVal Length As Long)
> Private Type BLENDFUNCTION
> BlendOp As Byte
> BlendFlags As Byte
> SourceConstantAlpha As Byte
> AlphaFormat As Byte
> End Type
> Private Const AC_SRC_OVER = &H0
> Private translucency As Byte
>
> Private Sub Form_Load()
> Me.WindowState = vbMaximized
> picBackground.ScaleMode = vbPixels
> picBackground.AutoSize = True
> picBackground.AutoRedraw = True
> picBackground.Move 0, 0
> picSprite.AutoRedraw = True
> picSprite.ScaleMode = vbPixels
> picSprite.AutoSize = True
> picSprite.Visible = False
> picTemp.AutoRedraw = True
> picTemp.ScaleMode = vbPixels
> picTemp.Visible = False
> ' load a main background picture at and display it
> ' at its full original image size for initial test
> ' purposes (regardless of whether it overflows the
> ' screen or not)
> picBackground.Picture = LoadPicture("c:\temp\jessica2.jpg")
> ' load a sprite image (any small image will do,
> ' although something that looks like a typical
> ' sprite would be best). In this specific example when
> ' we actually draw it as a sprite we will use the colour
> ' of the pixel at its top left corner as the desired
> ' transparent colour (although you can instead use your
> ' own sprite and mask images if you wish - see notes in
> ' the DrawSpriteTranslucent routine below.
> picSprite.Picture = LoadPicture("c:\temp\bear.bmp")
> Set HScroll1.Container = picBackground
> HScroll1.Min = 0
> HScroll1.Max = 255
> HScroll1.LargeChange = 50
> HScroll1.Value = 128
> HScroll1.Move 0, 0, 160, 28
> HScroll1.TabStop = False
> End Sub
>
> Private Sub DrawSpriteTranslucent(X As Long, _
> Y As Long, transClr As Long, translucency As Byte)
> ' Mike Williams (2010)
> Dim BF1 As BLENDFUNCTION, lBF As Long
> Dim wide As Long, high As Long
> wide = picSprite.ScaleWidth
> high = picSprite.ScaleHeight
> picTemp.Width = picSprite.Width
> picTemp.Height = picSprite.Height
> ' First grab a "sprite sized" rectangle of the
> ' existing background from the spot where we want
> ' to draw our sprite (so that the existing
> ' background at that position ends up in our
> ' temp PictureBox)
> BitBlt picTemp.hdc, 0, 0, wide, high, _
> picBackground.hdc, X, Y, vbSrcCopy
> ' Now perform a standard transparent blit of the
> ' sprite into temp PicBox over the top of the
> ' background stuff we just grabbed. In this example
> ' we are using the TransparentBlt API (which used
> ' to have a memory leak but is fine now in XP/Vista
> ' and later) and we are passing it the colour that
> ' we wish to be treated as transparent but you can
> ' instead use your own favourite method of
> ' transparently blitting a sprite using two separate
> ' blits of mask and image if you wish.
> TransparentBlt picTemp.hdc, 0, 0, wide, high, _
> picSprite.hdc, 0, 0, wide, high, transClr
> ' Now set up our blend to use the desired translucency
> With BF1
> .BlendOp = AC_SRC_OVER
> .BlendFlags = 0
> .SourceConstantAlpha = translucency
> .AlphaFormat = 0
> End With
> CopyMemory lBF, BF1, 4
> ' The temp PicBox currently contains the appropriate
> ' portion of the main background image with the sprite
> ' transparently drawn on top of it, so we can now
> ' blend that composite image into the main background
> ' PicBox, which will result in only the "sprite"
> ' pixels being blended in because all other pixels
> ' in picTemp are the same as those already in the
> ' background PicBox, and any blend of two identical
> ' colour pixels results in the original colour
> AlphaBlend picBackground.hdc, X, Y, wide, _
> high, picTemp.hdc, 0, 0, _
> wide, high, lBF
> ' Refresh the background PicBox so we can see the result
> picBackground.Refresh
> End Sub
>
> Private Sub HScroll1_Change()
> Me.Caption = "Translucency is currently " & Format _
> (HScroll1.Value) & " (Use slider to change). " _
> & " Click picture to draw sprite."
> translucency = HScroll1.Value
> End Sub
>
> Private Sub HScroll1_Scroll()
> Call HScroll1_Change
> End Sub
>
> Private Sub picBackground_MouseDown(Button As Integer, _
> Shift As Integer, X As Single, Y As Single)
> ' Alphablend the image in picSprite transparently
> ' onto our main picture (background) at the clicked
> ' location
> Dim xp As Long, yp As Long, transColor As Long
> ' first adjust the coordinates of the click so that
> ' the centre of the sprite will end up at that position
> xp = X - picSprite.ScaleWidth / 2 ' centre on clicked point
> yp = Y - picSprite.ScaleHeight / 2 ' centre on clicked point
> ' now read the pixel in the top left corner of the sprite
> ' image and assume that to be the desired transparent
> ' colour
> transColor = picSprite.Point(0, 0)
> ' draw the sprite onto the backgeound picture transparently
> ' with the non transparent sprite area blended in using the
> ' alpha translucency as determined by the position of the
> ' slider (this value is set in HScroll1 Change etc event)
> DrawSpriteTranslucent xp, yp, transColor, translucency
> End Sub
>
>
> .
>
From: Mike Williams on
"Bee" <Bee(a)discussions.microsoft.com> wrote in message
news:E4CC0A9D-B64D-4A94-9945-63189920C93A(a)microsoft.com...

> Wow. Got it working. Added mousemove to position the
> sprite. Now I see what you were talking about using your
> method to create the sprite. Much better and more flexible.

Actually it's just a fairly standard method of drawing sprites, where there
is one sprite image and where the required mask is created from that image
in code. Similar methods are used all the time by most people. The only
difference here is that I am using the transparentBlt API, which effectively
creates the required mask itself "under the hood" (or takes similar
appropriate action) and so you do not need to add your own code to create
the mask, which would be the case if you were using multiple BitBlts. These
methods work well when the desired transparent colour is /only/ in the
transparent areas of the original image. Images which were created as .bmp
files specifically for use as sprites often follow that rule, where for
example the transparent areas might be white (or whatever other colour you
are using to signify transparency) and all other areas (the non transparent
areas) are something other than white, and in such images any "looks like
white" part of the non transparent part of the image will be "nearly white",
so that it actually gets drawn. Such images will have been specifically
drawn in that way.

However, there will be other images which were not drawn as .bmp files
specifically for use as a sprite (perhaps they were intended only for
drawing onto a white printer page or perhaps they are a .bmp file you have
created from an image format which itself contains individual pixel
transparency information (such as a gif). In such cases it is possible that
pure white (or whatever is used as the transparent colour) in the .bmp file
is used both in the transparent area and also in part of the non transparent
area, the whites of an eye for example. Those kind of .bmp images when drawn
as sprites cannot properly be dealt with using the normal "create a mask on
the fly in code" method or the transparentBlt method because only the author
of the image (or some other person looking at it from a common sense point
of view) can know for certain which parts are supposed to be transparent and
which are not. Computers are absolute rubbish at making such decisions
(although there are certain specific cases where with a lot of work they can
be coded to make quite good guesses) but people are very good at that sort
of thing. If you are drawing the original image yourself in code of course
then your code can draw either just an original image or both an image and a
mask, because your code is effectively the author and therefore your code
knows exactly what parts are supposed to be transparent) but if you are
dealing with such an original image that was drawn by somebody else or a
..bmp that was created from an original .gif image then it really is best if
a real person can manually load the.bmp into a paint program and manually
create a suitable "black on white" mask from it by painting all desired
transparent areas in the mask pure white and all non transparent areas pure
black (or vice versa). Such a sprite then of course has two original images
associated with it (the sprite and the mask) and so it cannot be properly
dealt with by the transparentBlt API and neither can you create a mask "on
the fly in code". In such cases (where a suitable mask is provided by the
author of the image) then you need to use the standard "at least two blits"
method to draw the sprite.

> I find it very difficult to grasp these concepts. No
> graphics training at all here. Still learning.

I've had no formal training myself in these matters, but I've been meddling
about with certain graphic related stuff on and off for years and over a
long period of time you're bound to pick up a lot of good stuff (and a lot
of bad stuff sometimes!). I am also still learning, as we all are. It might
seem a bit complicated to you just now, but one day it will all start to
fall into place. You'll never get to the stage where you know everything,
nobody ever does, but it will one day all seem much easier . . until they
change everything of course, and perhaps get rid of GDI32 completely, in
which case you will have to start to learn much of it all over again (!),
although basic principles are still always basic principles and they will
stand you in good stead whatever happens.

> Using old gray matter. Taking my vitamins too.

That's the ticket. Keep taking the tablets ;-) I think I'm a few years
older than you are, and I take so many tablets that I rattle when I move
quickly, or at least as quickly as it is possible for me to move these days
;-)

Mike



From: Bee on
Mike,
This is my plan. I have several parts of this all working and I will
probably change over to use you methiod since it is simpler and I think it
will work for my use.

My app has tools to create or manipulate any image that can be loaded into a
picture box. Manipulated images are saved as bmp.

The user selects a tranparency color from either a colorpicker(my design) or
by pipette (eyedropper to some) from anything loaded or even from the screen.

Only externally created images that are compatible are allowed. And
external images can be modified in my app to meet the requirements.

I also have the facility to allow the user to load an image to use as a
sprite and identify a color to use as transparency. then click a button and
change that color in the entire image to a slightly (one bit different) color
so tht the user can paint the sprite with the transparency color for those
transparent areas as desired. This is saved as a BMP. Thus if for some
reason the user desires, the same (almost) color can be used in the image and
as the transparency color (maybe for his/her use elsewhere).
I do not trust JPG images to renter purely and thus maintain their
spritleyness so I am sticking with BMP. The final composite image can be
saved as JPG(selectable compression) or BMP.

The user can load the sprite and size, position, flip or rotate over another
image.

First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Simple Obfuscation
Next: Flag test