MCPcopy Create free account
hub / github.com/LemonOSProject/LemonOS / surfacecpyTransparent

Function surfacecpyTransparent

LibLemon/src/gfx/graphics.cpp:284–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

282 }
283
284 void surfacecpyTransparent(surface_t* dest, surface_t* src, vector2i_t offset){
285 uint32_t* srcBuffer = (uint32_t*)src->buffer;
286 uint32_t* destBuffer = (uint32_t*)dest->buffer;
287 for(int i = 0; i < src->height && i < dest->height - offset.y; i++){
288 for(int j = 0; j < src->width && j < dest->width - offset.x; j++){
289 uint32_t sPixel = (srcBuffer[i*src->width + j]);
290 if(!((sPixel >> 24) & 0xFF)) continue; // Check for 0 alpha
291
292 if(((sPixel >> 24) & 0xFF) >= 255){ // Check for full alpha
293 destBuffer[(i+offset.y)*dest->width + j + offset.x] = srcBuffer[i*src->width + j];
294 } else {
295 destBuffer[(i+offset.y)*dest->width + j + offset.x] = AlphaBlend(destBuffer[(i+offset.y)*dest->width + j + offset.x], (sPixel >> 16) & 0xFF, (sPixel >> 8) & 0xFF, sPixel & 0xFF, ((sPixel >> 24) & 0xFF) * 1.0 / 255);
296 }
297 }
298 }
299 }
300
301 void surfacecpyTransparent(surface_t* dest, surface_t* src, vector2i_t offset, rect_t srcRegion){
302 int srcWidth = (srcRegion.pos.x + srcRegion.size.x) > src->width ? (src->width - srcRegion.pos.x) : srcRegion.size.x;

Callers 5

DrawMethod · 0.85
PaintMethod · 0.85
PaintMethod · 0.85
PaintMethod · 0.85
OnTaskbarPaintFunction · 0.85

Calls 1

AlphaBlendFunction · 0.85

Tested by

no test coverage detected