Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color Extraction Developer Insights
#5
(01-28-2024, 07:16 AM)SMcNeill Wrote: A better way may be to just get values directly.

$Checking:off
Alpha = _MEMGET(m, o +3, _unsigned _byte)
Red = _MEMGET(m, o + 2, unsigned byte)
Green...   o + 1
Blue ... o
$Checking:on

No shifting, no calculations.  Just a direct value read.

(When then goes to the speed question: is it faster to just read 4 values directly, or to only read one and then math it?)

I'd *think* a simple direct read would be faster, but with cacheing and all nowadays...  I'd swear to nothing!  Wink
Leave it Steve to think even deeper. Very interesting and of course so simple I completely overlooked it.

One thing I noticed here is that because of the way you are reading offset values it appears that the bytes are ordered in BGRA. Is that correct Steve, was my bit manipulation efforts reading in the data backwards?
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
RE: Color Extraction Developer Insights - by TerryRitchie - 01-28-2024, 04:28 PM



Users browsing this thread: 3 Guest(s)