MCPcopy Create free account
hub / github.com/FastLED/FastLED / displayFrameOnLEDs

Function displayFrameOnLEDs

examples/Codec/codec_processor.cpp:211–228  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

209}
210
211void displayFrameOnLEDs(const fl::Frame& frame) {
212 for (int y = 0; y < ledHeight; y++) {
213 for (int x = 0; x < ledWidth; x++) {
214 // Calculate source pixel coordinates (with scaling)
215 int srcX = (x * (int)frame.getWidth()) / ledWidth;
216 int srcY = (y * (int)frame.getHeight()) / ledHeight;
217
218 // Get pixel from frame
219 CRGB color = getPixelFromFrame(frame, srcX, srcY);
220
221 // Set LED color
222 int ledIndex = y * ledWidth + x;
223 if (ledIndex < numLeds) {
224 leds[ledIndex] = color;
225 }
226 }
227 }
228}
229
230CRGB getPixelFromFrame(const fl::Frame& frame, int x, int y) {
231 if (x >= (int)frame.getWidth() || y >= (int)frame.getHeight() || !frame.isValid()) {

Callers 3

processJpegFunction · 0.85
processGifFunction · 0.85
processMpeg1Function · 0.85

Calls 3

getPixelFromFrameFunction · 0.85
getWidthMethod · 0.45
getHeightMethod · 0.45

Tested by

no test coverage detected