FastLED 3.9.15
Loading...
Searching...
No Matches
bilinear_expansion.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 bilinearExpandArbitrary(const CRGB *input, CRGB *output,
23 uint16_t inputWidth, uint16_t inputHeight,
25
33void bilinearExpandPowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth,
34 uint8_t inputHeight, fl::XYMap xyMap);
35
36//
37inline void bilinearExpand(const CRGB *input, CRGB *output, uint16_t inputWidth,
38 uint16_t inputHeight, fl::XYMap xyMap) {
39 uint16_t outputWidth = xyMap.getWidth();
40 uint16_t outputHeight = xyMap.getHeight();
41 const bool wontFit =
42 (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight());
43 // if the input dimensions are not a power of 2 then we can't use the
44 // optimized version.
45 if (wontFit || (inputWidth & (inputWidth - 1)) ||
46 (inputHeight & (inputHeight - 1))) {
47 bilinearExpandArbitrary(input, output, inputWidth, inputHeight, xyMap);
48 } else {
49 bilinearExpandPowerOf2(input, output, inputWidth, inputHeight, xyMap);
50 }
51}
52
53// These are here for testing purposes and are slow. Their primary use
54// is to test against the fixed integer version above.
55void bilinearExpandFloat(const CRGB *input, CRGB *output, uint8_t inputWidth,
56 uint8_t inputHeight, fl::XYMap xyMap);
57
58void bilinearExpandArbitraryFloat(const CRGB *input, CRGB *output,
59 uint16_t inputWidth, uint16_t inputHeight,
61
62uint8_t bilinearInterpolateFloat(uint8_t v00, uint8_t v10, uint8_t v01,
63 uint8_t v11, float dx, float dy);
64
65} // namespace fl
XYMap xyMap(WIDTH, HEIGHT, false)
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
void bilinearExpand(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, fl::XYMap xyMap)
void bilinearExpandArbitraryFloat(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
void bilinearExpandFloat(const CRGB *input, CRGB *output, uint8_t inputWidth, uint8_t inputHeight, XYMap xyMap)
uint8_t bilinearInterpolateFloat(uint8_t v00, uint8_t v10, uint8_t v01, uint8_t v11, float dx, float dy)
void bilinearExpandArbitrary(const CRGB *input, CRGB *output, uint16_t inputWidth, uint16_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
void bilinearExpandPowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth, uint8_t inputHeight, XYMap xyMap)
Performs bilinear interpolation for upscaling an image.
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