Reads blue channel from locked image (requires b2dLockImage first, fast CPU buffer access, 0-255).
Takes imageHandle (locked image handle, positive integer, must have isLocked=true), x (horizontal pixel coordinate, integer, 0=left edge), y (vertical pixel coordinate, integer, 0=top edge).
Returns blue channel value (0-255 integer, 0=no blue, 255=full blue), returns 0 on error (not locked, invalid handle, or out-of-bounds coordinates).
2D Overlay
Parameters & Returns
Parameters
imageHandleInt
xInt
yInt
Returns
Int
Quick Summary
Reads blue channel from locked image (requires b2dLockImage first, fast CPU buffer access, 0-255).
Takes imageHandle (locked image handle, positive integer, must have isLocked=true), x (horizontal pixel coordinate, integer, 0=left edge), y (vertical pixel coordinate, integer, 0=top edge).
Returns blue channel value (0-255 integer, 0=no blue, 255=full blue), returns 0 on error (not locked, invalid handle, or out-of-bounds coordinates).
Technical Exegesis...
Reads blue channel from locked image (requires b2dLockImage first, fast CPU buffer access, 0-255). Takes imageHandle (locked image handle, positive integer, must have isLocked=true), x (horizontal pixel coordinate, integer, 0=left edge), y (vertical pixel coordinate, integer, 0=top edge). Returns blue channel value (0-255 integer, 0=no blue, 255=full blue), returns 0 on error (not locked, invalid handle, or out-of-bounds coordinates). Reads from CPU buffer (img.
Reads blue channel from locked image (requires b2dLockImage first, fast CPU buffer access, 0-255). Takes imageHandle (locked image handle, positive integer, must have isLocked=true), x (horizontal pixel coordinate, integer, 0=left edge), y (vertical pixel coordinate, integer, 0=top edge). Returns blue channel value (0-255 integer, 0=no blue, 255=full blue), returns 0 on error (not locked, invalid handle, or out-of-bounds coordinates). Reads from CPU buffer (img.cpuPixelBuffer, direct memory access), calculates pixel index (index = (yxwidth+x)x4 row-major RGBA layout), returns B byte (buffer[index+2] blue channel at offset 2). Use to sample color (read pixel colors for analysis), detect water/sky (high blue values), implement collision (check color channels at overlap), or process image data (filters, effects, color-based logic). Lock requirement: MUST call b2dLockImage first (downloads texture to CPU buffer, enables pixel access), fast access (direct CPU memory read, no GPU overhead per pixel), many reads efficient (one lock enables many GetPixel calls without GPU round-trips). Use cases: (1) Full color sampling (r=b2dGetPixelR(img,x,y): g=b2dGetPixelG(img,x,y): b=b2dGetPixelB(img,x,y) read RGB), (2) Find blue pixels (For y=0 To h: For x=0 To w: If b2dGetPixelB(img,x,y)>200 Then found bright blue), (3) Dominant blue detection (If b2dGetPixelB(img,x,y)>b2dGetPixelR(img,x,y) And b2dGetPixelB(img,x,y)>b2dGetPixelG(img,x,y) Then bluish pixel), (4) Color distance (dr=r1-b2dGetPixelR(img2,x,y): dg=g1-b2dGetPixelG(img2,x,y): db=b1-b2dGetPixelB(img2,x,y): dist=Sqr(dr*dr+dg*dg+db*db) compare colors), (5) Luminance calculation (lum=0.299*b2dGetPixelR+0.587*b2dGetPixelG+0.114*b2dGetPixelB weighted grayscale). Common patterns: read RGB = r=b2dGetPixelR: g=b2dGetPixelG: b=b2dGetPixelB full color; dominant blue = If b>r And b>g Then mostly blue. RGBA format: R at offset+0 (red channel), G at offset+1 (green channel), B at offset+2 (blue channel third byte), A at offset+3 (alpha channel), 4 bytes per pixel (RGBA tightly packed). Coordinate system: origin top-left (0,0 = top-left corner), x rightward (0=left edge, width-1=right edge), y downward (0=top edge, height-1=bottom edge), row-major layout (left-to-right, top-to-bottom). Index calculation: pixel index = (y x width + x) x 4 (offset to pixel's first byte), B byte = buffer[index+2] (add 2 for blue channel), bounds check (x in 0 to width-1, y in 0 to height-1), out-of-bounds returns 0 (silently returns 0 for invalid coordinates). Performance: access cost zero (direct CPU memory read, single array index), no GPU overhead (reads from CPU buffer, no GPU round-trips), amortized lock cost (one lock enables many reads), efficient for batch operations (reading many pixels faster than GPU per-pixel access). Validation: prints error if not locked (img.isLocked=false or cpuPixelBuffer=nullptr, returns 0), returns 0 if invalid handle (imageHandle not in g_images map), returns 0 if out-of-bounds (x<0 or x>=width or y<0 or y>=height), no coordinate adjustment (only validates, doesn't clamp). Related: b2dGetPixelR reads red channel (same usage, offset+0), b2dGetPixelG reads green channel (same usage, offset+1), b2dGetPixelA reads alpha channel (same usage, offset+3), b2dLockImage enables access (required before this function), b2dUnlockImage completes cycle (required after done reading), b2dSetPixel writes pixel (modifies locked image).