Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
11-19-2022, 06:28 PM
(This post was last modified: 11-19-2022, 06:34 PM by bplus.)
Quote:I am Minerva with the Glinting Eyes going looking for wisdom.
OK Minerva MwtGEglfW
I have been disappointed by QB64 needing _RGB32 colors that the &H.... ones don't work as constants without some added suffixes either in constant name Yikes! or in number value Yikes ^2. Of course I don't remember which because the rules changed somewhere around the v2.0. I find this out when I use Point().
We can't say &B1011 for a binary number but we have to say &HFFFFFFFF~& for Constant White.
b = b + ...
Posts: 733
Threads: 103
Joined: Apr 2022
Reputation:
14
11-19-2022, 08:44 PM
(This post was last modified: 11-19-2022, 08:46 PM by madscijr.)
(11-19-2022, 01:22 AM)bplus Wrote: Don't know what you are doing but:
Code: (Select All) Screen _NewImage(800, 600, 32)
Line (100, 100)-Step(100, 100), _RGB32(255, 0, 0, 236), BF
Line (300, 100)-Step(100, 100), _RGB32(255, 0, 0, 237), BF
If Point(150, 150) = Point(350, 150) Then Print "I'm a monkey's uncle." Else Print "Ha!"
Circle (150, 150), 5
Circle (350, 150), 5
Point can distinguish between 2 alpha settings!
Hmmm... I believe you, but why the heck is this test not working for alpha values?
And why am I wasting my Saturday on this nonsense?! LoL.
If anyone can find what's wrong, great, if not, I understand if you have better things to do!
(Thanks all for your contributions, BTW!)
Code: (Select All) Const FALSE = 0
Const TRUE = Not FALSE
Type CompareType
r1 As Long
g1 As Long
b1 As Long
a1 As Long
r2 As Long
g2 As Long
b2 As Long
a2 As Long
End Type
ReDim arrCompare(-1) As CompareType
Dim As _Unsigned Long p1
Dim As _Unsigned Long p2
Dim image1&
Dim image2&
Dim total$
Dim rgb1$
Dim rgb2$
Dim r1&, g1&, b1&, a1&
Dim r2&, g2&, b2&, a2&
' INITIALIZE
Screen _NewImage(1024, 768, 32): _Dest 0: Cls , cBlack
image1& = _NewImage(100, 100, 32)
image2& = _NewImage(100, 100, 32)
' READ TEST COLORS
Restore TestData
For iLoop% = 1 To 1000
Read r1&: Read g1&: Read b1&: Read a1&
Read r2&: Read g2&: Read b2&: Read a2&
Print _Trim$(Str$(r1&)) + ", " + _Trim$(Str$(g1&)) + ", " + _Trim$(Str$(b1&)) + ", " + _Trim$(Str$(a1&))
Print _Trim$(Str$(r2&)) + ", " + _Trim$(Str$(g2&)) + ", " + _Trim$(Str$(b2&)) + ", " + _Trim$(Str$(a2&))
If r1& = -2 Then Exit For
ReDim _Preserve arrCompare(UBound(arrCompare) + 1) As CompareType
arrCompare(UBound(arrCompare)).r1 = r1&
arrCompare(UBound(arrCompare)).g1 = g1&
arrCompare(UBound(arrCompare)).b1 = b1&
arrCompare(UBound(arrCompare)).a1 = a1&
arrCompare(UBound(arrCompare)).r2 = r2&
arrCompare(UBound(arrCompare)).g2 = g2&
arrCompare(UBound(arrCompare)).b2 = b2&
arrCompare(UBound(arrCompare)).a2 = a2&
'print "UBOUND(arrCompare) = " + _Trim$(Str$(UBOUND(arrCompare)))
Next iLoop%
'print "LBOUND(arrCompare) = " + _Trim$(Str$(LBOUND(arrCompare)))
'print "UBOUND(arrCompare) = " + _Trim$(Str$(UBOUND(arrCompare)))
'print "Finished reading data. Press any key to begin testing." : sleep
TestData:
' -1 means no alpha channel, -2 means end of data
Data 255,0,0,-1
Data 0,0,255,-1
Data 128,128,128,-1
Data 64,64,64,-1
Data 0,255,255,-1
Data 0,254,254,-1
Data 255,0,0,255
Data 255,0,0,-1
Data 255,0,0,254
Data 255,0,0,-1
Data 255,0,0,253
Data 255,0,0,-1
Data 255,0,0,255
Data 255,0,0,254
Data 255,0,0,255
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,251
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
' TEST WITH VARIOUS COMBINATIONS OF ALPHA VALUES AND NO ALPHA VALUES
total$ = " of " + _Trim$(Str$(UBound(arrCompare)))
For iLoop% = LBound(arrCompare) To UBound(arrCompare)
' GET COLOR #1
If arrCompare(iLoop%).a1 < 0 Then
p1 = _RGB32(arrCompare(iLoop%).r1, arrCompare(iLoop%).g1, arrCompare(iLoop%).b1)
rgb1$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b1)) + ")"
Else
p1 = _RGB32(arrCompare(iLoop%).r1, arrCompare(iLoop%).g1, arrCompare(iLoop%).b1, arrCompare(iLoop%).a1)
rgb1$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).a1)) + ")"
End If
_Dest image1&
Line (1, 1)-(100, 100), p1, BF ' Draw a solid box
_Source image1&
p1 = Point(50, 50)
r1& = _Red32(p1): g1& = _Green32(p1): b1& = _Blue32(p1): a1& = _Alpha32(p1)
Circle (50, 50), 5
' GET COLOR #2
If arrCompare(iLoop%).a2 < 0 Then
p2 = _RGB32(arrCompare(iLoop%).r2, arrCompare(iLoop%).g2, arrCompare(iLoop%).b2)
rgb2$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b2)) + ")"
Else
p2 = _RGB32(arrCompare(iLoop%).r2, arrCompare(iLoop%).g2, arrCompare(iLoop%).b2, arrCompare(iLoop%).a2)
rgb2$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).a2)) + ")"
End If
_Dest image2&
Line (1, 1)-(100, 100), p2, BF ' Draw a solid box
_Source image2&
p2 = Point(50, 50)
r2& = _Red32(p2): g2& = _Green32(p2): b2& = _Blue32(p2): a2& = _Alpha32(p2)
Circle (50, 50), 5
' SHOW RESULTS
_Dest 0: Cls , cBlack
Locate 2, 1: Print "Compare image alpha values, test " + _Trim$(Str$(iLoop%)) + total$
Locate 10, 3: Print "image1&:";
Locate 10, 28: Print "image2&:";
_PutImage (100, 100), image1&, 0
_PutImage (300, 100), image2&, 0
Locate 14, 1
Print "Comparing " + rgb1$ + _
" _Source image1& : p1 = Point(50, 50) = " + _Trim$(Str$(p1%)) + _
"_RED=" + _Trim$(Str$(r1&)) + ", " + "_GREEN=" + _Trim$(Str$(g1&)) + ", " + "_BLUE=" + _Trim$(Str$(b1&)) + ", " + "_ALPHA=" + _Trim$(Str$(a1&))
Print " with " + rgb2$ + _
" _Source image2& : p2 = Point(50, 50) = " + _Trim$(Str$(p2%)) + _
"_RED=" + _Trim$(Str$(r2&)) + ", " + "_GREEN=" + _Trim$(Str$(g2&)) + ", " + "_BLUE=" + _Trim$(Str$(b2&)) + ", " + "_ALPHA=" + _Trim$(Str$(a2&))
Print
' comparing points
Print "Compare images with Point(x, y):"
If p1 = p2 Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
' bplus's function
Print "Compare images with Function CompareImages&:"
If CompareImages&(image1&, image2&) = TRUE Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
' bplus's function prettified by madsci
Print "Compare images with Function CompareImagesBPlus%:"
If CompareImagesBPlus%(image1&, image2&) = TRUE Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
If iLoop% < UBound(arrCompare) Then Print "Press any key to continue": Sleep
_KeyClear
Next iLoop%
' cleanup
If image1& < -1 Then _FreeImage image1&
If image2& < -1 Then _FreeImage image2&
' done
Print "That concludes our test. Press any key to exit..."
Sleep
System
'DrawRectSolid x%, y%, width%, height%, fgColor~&
Sub DrawRectSolid (iX As Integer, iY As Integer, iSizeW As Integer, iSizeH As Integer, fgColor As _Unsigned Long)
Line (iX, iY)-(iX + (iSizeW - 1), iY + (iSizeH - 1)), fgColor, BF ' Draw a solid rectangle
End Sub ' DrawRectSolid
' /////////////////////////////////////////////////////////////////////////////
' FROM: bplus
' https://qb64phoenix.com/forum/showthread.php?tid=1151&pid=10262#pid10262
' Don't know what you are doing but:
' Point can distinguish between 2 alpha settings!
Sub TestPointAlpha
Screen _NewImage(800, 600, 32)
Line (100, 100)-Step(100, 100), _RGB32(255, 0, 0, 236), BF
Line (300, 100)-Step(100, 100), _RGB32(255, 0, 0, 237), BF
If Point(150, 150) = Point(350, 150) Then Print "I'm a monkey's uncle." Else Print "Ha!"
Circle (150, 150), 5
Circle (350, 150), 5
End Sub ' TestPointAlpha
' /////////////////////////////////////////////////////////////////////////////
' FROM: bplus
' https://qb64phoenix.com/forum/showthread.php?tid=1151&pid=10242#pid10242
' Well my idea didn't take so long for one compare, just blink and there's your answer:
' Not nearly as quick as memory methods though.
' b = b + ...
Function CompareImages& (handle1 As Long, handle2 As Long)
Dim As _Unsigned Long p1
For y = 0 To _Height(handle1) - 1
For x = 0 To _Width(handle1) - 1
_Source handle1
p1 = Point(x, y)
_Source handle2
If Point(x, y) <> p1 Then Exit Function
Next
Next
CompareImages& = -1
End Function
Function CompareImagesBPlus% (handle1 As Long, handle2 As Long)
Dim bResult%: bResult% = TRUE
Dim p1 As _Unsigned Long
Dim y, x As Integer
Dim bFinished%: bFinished% = FALSE
For y = 0 To _Height(handle1) - 1
For x = 0 To _Width(handle1) - 1
_Source handle1
p1 = Point(x, y)
_Source handle2
If Point(x, y) <> p1 Then
bResult% = FALSE
bFinished% = FALSE
Exit For
End If
Next x
If bFinished% = TRUE Then Exit For
Next y
CompareImagesBPlus% = bResult%
End Function ' CompareImagesBPlus%
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
11-19-2022, 10:54 PM
(This post was last modified: 11-19-2022, 10:57 PM by bplus.)
TestData:
' -1 means no alpha channel, -2 means end of data
Data 255,0,0,-1
Data 0,0,255,-1
Data 128,128,128,-1
Data 64,64,64,-1
Data 0,255,255,-1
Data 0,254,254,-1
Data 255,0,0,255
Data 255,0,0,-1
Data 255,0,0,254
Data 255,0,0,-1
Data 255,0,0,253
Data 255,0,0,-1
Data 255,0,0,255
Data 255,0,0,254
Data 255,0,0,255
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,251
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
I think 255 = no alpha for _RGB32 color which meaqns it's a solid color
No something else is wrong.
b = b + ...
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
yeah alpha = 255 then no difference to no alpha color
Code: (Select All) Screen _NewImage(800, 600, 32)
Dim i As Long
For i = 0 To 255
Cls
Line (100, 100)-Step(100, 100), _RGB32(255, 0, 0, i), BF
Line (300, 100)-Step(100, 100), _RGB32(255, 0, 0), BF
If Point(150, 150) = Point(350, 150) Then
Print "When alpha ="; i; " have NO difference, zzz ..."
Else
Print "When alpha ="; i; " have difference, zzz ..."
End If
Sleep
Next
b = b + ...
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
Well this is quicker
Code: (Select All) Print _RGB32(255, 0, 0)
Print _RGB32(255, 0, 0, 255)
Print _RGB32(255, 0, 0, -1)
b = b + ...
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
Code: (Select All) Const FALSE = 0
Const TRUE = Not FALSE
Type CompareType
r1 As Long
g1 As Long
b1 As Long
a1 As Long
r2 As Long
g2 As Long
b2 As Long
a2 As Long
End Type
ReDim arrCompare(-1) As CompareType
Dim As _Unsigned Long p1
Dim As _Unsigned Long p2
Dim image1&
Dim image2&
Dim total$
Dim rgb1$
Dim rgb2$
Dim r1&, g1&, b1&, a1&
Dim r2&, g2&, b2&, a2&
' INITIALIZE
Screen _NewImage(1024, 768, 32): _Dest 0: Cls , cBlack
image1& = _NewImage(100, 100, 32)
image2& = _NewImage(100, 100, 32)
_DontBlend
' READ TEST COLORS
Restore TestData
For iLoop% = 1 To 1000
Read r1&: Read g1&: Read b1&: Read a1&
Read r2&: Read g2&: Read b2&: Read a2&
Print _Trim$(Str$(r1&)) + ", " + _Trim$(Str$(g1&)) + ", " + _Trim$(Str$(b1&)) + ", " + _Trim$(Str$(a1&))
Print _Trim$(Str$(r2&)) + ", " + _Trim$(Str$(g2&)) + ", " + _Trim$(Str$(b2&)) + ", " + _Trim$(Str$(a2&))
If r1& = -2 Then Exit For
ReDim _Preserve arrCompare(UBound(arrCompare) + 1) As CompareType
arrCompare(UBound(arrCompare)).r1 = r1&
arrCompare(UBound(arrCompare)).g1 = g1&
arrCompare(UBound(arrCompare)).b1 = b1&
arrCompare(UBound(arrCompare)).a1 = a1&
arrCompare(UBound(arrCompare)).r2 = r2&
arrCompare(UBound(arrCompare)).g2 = g2&
arrCompare(UBound(arrCompare)).b2 = b2&
arrCompare(UBound(arrCompare)).a2 = a2&
'print "UBOUND(arrCompare) = " + _Trim$(Str$(UBOUND(arrCompare)))
Next iLoop%
'print "LBOUND(arrCompare) = " + _Trim$(Str$(LBOUND(arrCompare)))
'print "UBOUND(arrCompare) = " + _Trim$(Str$(UBOUND(arrCompare)))
'print "Finished reading data. Press any key to begin testing." : sleep
TestData:
' -1 means no alpha channel, -2 means end of data
Data 255,0,0,-1
Data 0,0,255,-1
Data 128,128,128,-1
Data 64,64,64,-1
Data 0,255,255,-1
Data 0,254,254,-1
Data 255,0,0,255
Data 255,0,0,-1
Data 255,0,0,254
Data 255,0,0,-1
Data 255,0,0,253
Data 255,0,0,-1
Data 255,0,0,255
Data 255,0,0,254
Data 255,0,0,255
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,253
Data 255,0,0,254
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,252
Data 255,0,0,253
Data 255,0,0,251
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
Data -2,-2,-2,-2
' TEST WITH VARIOUS COMBINATIONS OF ALPHA VALUES AND NO ALPHA VALUES
total$ = " of " + _Trim$(Str$(UBound(arrCompare)))
For iLoop% = LBound(arrCompare) To UBound(arrCompare)
' GET COLOR #1
If arrCompare(iLoop%).a1 < 0 Then
p1 = _RGB32(arrCompare(iLoop%).r1, arrCompare(iLoop%).g1, arrCompare(iLoop%).b1)
rgb1$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b1)) + ")"
Else
p1 = _RGB32(arrCompare(iLoop%).r1, arrCompare(iLoop%).g1, arrCompare(iLoop%).b1, arrCompare(iLoop%).a1)
rgb1$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b1)) + ", " + _Trim$(Str$(arrCompare(iLoop%).a1)) + ")"
End If
_Dest image1&
Line (1, 1)-(100, 100), p1, BF ' Draw a solid box
_Source image1&
p1 = Point(50, 50)
r1& = _Red32(p1): g1& = _Green32(p1): b1& = _Blue32(p1): a1& = _Alpha32(p1)
Circle (50, 50), 5
' GET COLOR #2
If arrCompare(iLoop%).a2 < 0 Then
p2 = _RGB32(arrCompare(iLoop%).r2, arrCompare(iLoop%).g2, arrCompare(iLoop%).b2)
rgb2$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b2)) + ")"
Else
p2 = _RGB32(arrCompare(iLoop%).r2, arrCompare(iLoop%).g2, arrCompare(iLoop%).b2, arrCompare(iLoop%).a2)
rgb2$ = "_RGB32(" + _Trim$(Str$(arrCompare(iLoop%).r2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).g2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).b2)) + ", " + _Trim$(Str$(arrCompare(iLoop%).a2)) + ")"
End If
_Dest image2&
Line (1, 1)-(100, 100), p2, BF ' Draw a solid box
_Source image2&
p2 = Point(50, 50)
r2& = _Red32(p2): g2& = _Green32(p2): b2& = _Blue32(p2): a2& = _Alpha32(p2)
Circle (50, 50), 5
' SHOW RESULTS
_Dest 0: Cls , cBlack
Locate 2, 1: Print "Compare image alpha values, test " + _Trim$(Str$(iLoop%)) + total$
Locate 10, 3: Print "image1&:";
Locate 10, 28: Print "image2&:";
_PutImage (100, 100), image1&, 0
_PutImage (300, 100), image2&, 0
Locate 14, 1
Print "Comparing " + rgb1$ + _
" _Source image1& : p1 = Point(50, 50) = " + _Trim$(Str$(p1%)) + _
"_RED=" + _Trim$(Str$(r1&)) + ", " + "_GREEN=" + _Trim$(Str$(g1&)) + ", " + "_BLUE=" + _Trim$(Str$(b1&)) + ", " + "_ALPHA=" + _Trim$(Str$(a1&))
Print " with " + rgb2$ + _
" _Source image2& : p2 = Point(50, 50) = " + _Trim$(Str$(p2%)) + _
"_RED=" + _Trim$(Str$(r2&)) + ", " + "_GREEN=" + _Trim$(Str$(g2&)) + ", " + "_BLUE=" + _Trim$(Str$(b2&)) + ", " + "_ALPHA=" + _Trim$(Str$(a2&))
Print
' comparing points
Print "Compare images with Point(x, y):"
If p1 = p2 Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
' bplus's function
Print "Compare images with Function CompareImages&:"
If CompareImages&(image1&, image2&) = TRUE Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
' bplus's function prettified by madsci
Print "Compare images with Function CompareImagesBPlus%:"
If CompareImagesBPlus%(image1&, image2&) = TRUE Then
Print "No difference detected: I'm a monkey's uncle."
Else
Print "Different: Ha!"
End If
Print
If iLoop% < UBound(arrCompare) Then Print "Press any key to continue": Sleep
_KeyClear
Next iLoop%
' cleanup
If image1& < -1 Then _FreeImage image1&
If image2& < -1 Then _FreeImage image2&
' done
Print "That concludes our test. Press any key to exit..."
Sleep
System
'DrawRectSolid x%, y%, width%, height%, fgColor~&
Sub DrawRectSolid (iX As Integer, iY As Integer, iSizeW As Integer, iSizeH As Integer, fgColor As _Unsigned Long)
Line (iX, iY)-(iX + (iSizeW - 1), iY + (iSizeH - 1)), fgColor, BF ' Draw a solid rectangle
End Sub ' DrawRectSolid
' /////////////////////////////////////////////////////////////////////////////
' FROM: bplus
' https://qb64phoenix.com/forum/showthread.php?tid=1151&pid=10262#pid10262
' Don't know what you are doing but:
' Point can distinguish between 2 alpha settings!
Sub TestPointAlpha
Screen _NewImage(800, 600, 32)
Line (100, 100)-Step(100, 100), _RGB32(255, 0, 0, 236), BF
Line (300, 100)-Step(100, 100), _RGB32(255, 0, 0, 237), BF
If Point(150, 150) = Point(350, 150) Then Print "I'm a monkey's uncle." Else Print "Ha!"
Circle (150, 150), 5
Circle (350, 150), 5
End Sub ' TestPointAlpha
' /////////////////////////////////////////////////////////////////////////////
' FROM: bplus
' https://qb64phoenix.com/forum/showthread.php?tid=1151&pid=10242#pid10242
' Well my idea didn't take so long for one compare, just blink and there's your answer:
' Not nearly as quick as memory methods though.
' b = b + ...
Function CompareImages& (handle1 As Long, handle2 As Long)
Dim As _Unsigned Long p1
For y = 0 To _Height(handle1) - 1
For x = 0 To _Width(handle1) - 1
_Source handle1
p1 = Point(x, y)
_Source handle2
If Point(x, y) <> p1 Then Exit Function
Next
Next
CompareImages& = -1
End Function
Function CompareImagesBPlus% (handle1 As Long, handle2 As Long)
Dim bResult%: bResult% = TRUE
Dim p1 As _Unsigned Long
Dim y, x As Integer
Dim bFinished%: bFinished% = FALSE
For y = 0 To _Height(handle1) - 1
For x = 0 To _Width(handle1) - 1
_Source handle1
p1 = Point(x, y)
_Source handle2
If Point(x, y) <> p1 Then
bResult% = FALSE
bFinished% = FALSE
Exit For
End If
Next x
If bFinished% = TRUE Then Exit For
Next y
CompareImagesBPlus% = bResult%
End Function ' CompareImagesBPlus%
The issue is really rather simple -- all your values that you're comparing *ARE* exactly the same.
Let me ask you guys a simple question and then you tell me what happens: What happens when you put a 50 alpha image onto an already existing image?
Say for example, you normally have a pure black screen: 255 alpha, 0 red, 0 green, 0 blue.
Now, you decide to put a faded white color onto that screen: 50 alpha, 255 red, 255 green, 255 blue.
What is the final result that you get? Does it just add everything together and then divide by two? 150 alpha, 150 red, 150 green, 150 blue??
Think about it....
If you don't know, and don't want to give it a try to test, I'll go ahead and give you the answer:
When two colors blend together, the end result is a color with 255 alpha. Poll your display screen at any time you want, and check the alpha levels on it. 255. 255. 255. 255. Blend whatever you want onto it. 255. 255. 255. Toss full alpha at it... 255. 255. 255. Toss zero alpha at it.... 255. 255. 255. Toss 125 alpha at it.... 255. 255. 255. (Those 255's are your alpha levels.)
As long as blending is on, your display is always going to blend to 255 alpha. Your alpha check is telling you that all the screen colors have the same level of alpha with your display because they do!
Don't want that blending to blend everything to 255 alpha?
_DONTBLEND
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
I cls between tests.
b = b + ...
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
11-20-2022, 12:04 AM
(This post was last modified: 11-20-2022, 12:07 AM by SMcNeill.)
bplus's demo, modified to just check alpha levels and not colors themselves:
Code: (Select All) Screen _NewImage(800, 600, 32)
Dim i As Long
For i = 0 To 255
Cls
Line (100, 100)-Step(100, 100), _RGB32(255, 0, 0, i), BF
Line (300, 100)-Step(100, 100), _RGB32(255, 0, 0), BF
If _Alpha32(Point(150, 150)) = _Alpha32(Point(350, 150)) Then
Print "When alpha ="; i; " have NO difference, zzz ..."
Else
Print "When alpha ="; i; " have difference, zzz ..."
End If
Print Hex$(Point(150, 150)), Hex$(Point(350, 150))
Sleep
Next
Modified to print the actual color values that are on the screen for you.
Posts: 3,974
Threads: 177
Joined: Apr 2022
Reputation:
219
11-20-2022, 12:14 AM
(This post was last modified: 11-20-2022, 12:15 AM by bplus.)
Code: (Select All) Print _Alpha32(_RGB32(150, 0, 0)), _Alpha32(_RGB32(150, 0, 0, 0))
Print _Alpha32(_RGB32(150, 0, 0)), _Alpha32(_RGB32(150, 0, 0, 255))
b = b + ...
Posts: 2,696
Threads: 327
Joined: Apr 2022
Reputation:
217
(11-20-2022, 12:14 AM)bplus Wrote: Code: (Select All) Print _Alpha32(_RGB32(150, 0, 0)), _Alpha32(_RGB32(150, 0, 0, 0))
Print _Alpha32(_RGB32(150, 0, 0)), _Alpha32(_RGB32(150, 0, 0, 255))
Yes?? Is there a question in there somewhere?
_RGBA32 has no trouble giving you a zero alpha color value. But you having PSET that color onto your screen where it's blended with anything yet.... It's the PSET atop another color where the blending occurs, resulting in a 255 alpha color from the mixture.
|