MCPcopy Create free account
hub / github.com/WheretIB/nullc / CanvasCommit

Function CanvasCommit

NULLC/includes/canvas.cpp:330–348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

328 float saturate(float x){ if(x < 0.0) return 0.0; if(x > 255.0) return 255.0; return x; }
329
330 void CanvasCommit(Canvas* ptr)
331 {
332 if(!ptr)
333 {
334 nullcThrowError("ERROR: Canvas object is nullptr");
335 return;
336 }
337 int *pStart = (int*)ptr->dataI.ptr, *pEnd = (int*)ptr->dataI.ptr + ptr->width * ptr->height;
338 float *fStart = (float*)ptr->data.ptr;
339 for(int *pix = pStart; pix != pEnd; pix++)
340 {
341 int red = int(saturate(*fStart++ * 255.0f));
342 int green = int(saturate(*fStart++ * 255.0f));
343 int blue = int(saturate(*fStart++ * 255.0f));
344 fStart++;
345
346 *pix = (red << 16) | (green << 8) | (blue) | (255 << 24);
347 }
348 }
349}
350
351#define REGISTER_FUNC(funcPtr, name, index) if(!nullcBindModuleFunction("img.canvas", (void(*)())NULLCCanvas::funcPtr, name, index)) return false;

Callers 1

WindowDrawCanvasFunction · 0.85

Calls 2

saturateFunction · 0.70
nullcThrowErrorFunction · 0.50

Tested by

no test coverage detected