FastLED 3.9.15
Loading...
Searching...
No Matches
upscale.h
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <stdint.h>
8
9#include "crgb.h"
10#include "fl/namespace.h"
11#include "fl/xymap.h"
12
13namespace fl {
14
22void upscaleArbitrary(const CRGB *input, CRGB *output, uint16_t inputWidth,
23 uint16_t inputHeight, fl::XYMap xyMap);
24
32void upscalePowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth,
33 uint8_t inputHeight, fl::XYMap xyMap);
34
35//
36inline void upscale(const CRGB *input, CRGB *output, uint16_t inputWidth,
37 uint16_t inputHeight, fl::XYMap xyMap) {
38 uint16_t outputWidth = xyMap.getWidth();
39 uint16_t outputHeight = xyMap.getHeight();
40 const bool wontFit =
41 (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight());
42 // if the input dimensions are not a power of 2 then we can't use the
43 // optimized version.
44 if (wontFit || (inputWidth & (inputWidth - 1)) ||
45 (inputHeight & (inputHeight - 1))) {
46 upscaleArbitrary(input, output, inputWidth, inputHeight, xyMap);
47 } else {
48 upscalePowerOf2(input, output, inputWidth, inputHeight, xyMap);
49 }
50}
51
52// These are here for testing purposes and are slow. Their primary use
53// is to test against the fixed integer version above.
54void upscaleFloat(const CRGB *input, CRGB *output, uint8_t inputWidth,
55 uint8_t inputHeight, fl::XYMap xyMap);
56
57void upscaleArbitraryFloat(const CRGB *input, CRGB *output, uint16_t inputWidth,
58 uint16_t inputHeight, fl::XYMap xyMap);
59
60uint8_t upscaleFloat(uint8_t v00, uint8_t v10, uint8_t v01,
61 uint8_t v11, float dx, float dy);
62
63} // namespace fl
Defines the red, green, and blue (RGB) pixel struct.
XYMap xyMap
Definition gfx.cpp:8
Implements the FastLED namespace macros.
void upscale(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, fl::XYMap xyMap)
Definition upscale.h:36
void upscaleArbitrary(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
Definition upscale.cpp:20
uint8_t upscaleFloat(uint8_t v00, uint8_t v10, uint8_t v01, uint8_t v11, float dx, float dy)
Definition upscale.cpp:160
void upscalePowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth, uint8_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
Definition upscale.cpp:84
void upscaleArbitraryFloat(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
Definition upscale.cpp:181
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55