to figure out how to detect transparency on a texture (in my case, a button). What I want to do is to be able to detect if a point (mouse click) is on a transparent part of the texture or not. I think I understand how to do it for a texture normally, you get the texture's color data and find the point on the array created.
However I am trying to figure out how I could possibly do that with a texture I am drawing with rectangle bounds that shrink/grow the original image. Since the spritebatch draw routine takes the parameters for scaling/re-sizing, the texture2D object itself is not changed, and so there is no way I can find to get the color data for a re-sized texture. Here's the routine I have currently:
Public Shared Function IsAtAlpha(textureToCheck As Texture2D, textureLocation As Rectangle, pointToCheck As Point) As Boolean
Dim colorData As Color()
colorData = New Color((textureToCheck.Width * textureToCheck.Height) - 1) {}
textureToCheck.GetData(colorData)
Dim SpecificPointColor As Color = colorData((pointToCheck.X - textureLocation.Left) +
(pointToCheck.Y - textureLocation.Top) * textureToCheck.Width)
Return SpecificPointColor.A = 0
End Function
If I could get a resized texture2D object I know what to change to get this to work properly, but I have no clue how to get that. Or is there a better way to check for transparency here?






