Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Color Extraction Developer Insights
#1
I'm writing a few image manipulation routines and need them to be as fast as possible. I'm using bit manipulation to extract pixel color information like so:

(all of the variables have been declared properly beforehand)

_MEMGET m, o, p '            get pixel at offset within image memory block
a = 4278190080 AND p '  extract alpha
r = 16711680 AND p '      extract red
g = 65280 AND p '           extract green
b = 255 AND p '               get blue level (0 to 255)
a = _SHR(a, 24) '              get alpha level (0 to 255) (divide by 16777215)
r = _SHR(r, 16) '               get red level (0 to 255) (divide by 65536)
g = _SHR(g, 8) '               get green level (0 to 255) (divide by 256)

I need some insight from the developers regarding _ALPHA32(), _RED32(), _GREEN32(), and _BLUE32(). Is my bit manipulation faster than using these statements or are they handled internally using the same method (or an even faster method I'm unaware of)?

Loving the memory manipulation statements by the way. Man, have I been missing out by not using them regularly.
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Color Extraction Developer Insights - by TerryRitchie - 01-28-2024, 06:28 AM



Users browsing this thread: 3 Guest(s)