FastLED 3.9.7
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
13
14namespace fl {
15
23void bilinearExpandArbitrary(const CRGB *input, CRGB *output,
24 uint16_t inputWidth, uint16_t inputHeight,
25 fl::XYMap xyMap);
26
34void bilinearExpandPowerOf2(const CRGB *input, CRGB *output, uint8_t inputWidth, 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 = (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)) || (inputHeight & (inputHeight - 1))) {
45 bilinearExpandArbitrary(input, output, inputWidth, inputHeight, xyMap);
46 } else {
47 bilinearExpandPowerOf2(input, output, inputWidth, inputHeight, xyMap);
48 }
49}
50
51void bilinearExpandFloat(const CRGB *input, CRGB *output,
52 uint8_t inputWidth, uint8_t inputHeight,
53 fl::XYMap xyMap);
54
55void bilinearExpandArbitraryFloat(const CRGB *input, CRGB *output,
56 uint16_t inputWidth, uint16_t inputHeight,
57 fl::XYMap xyMap);
58
59uint8_t bilinearInterpolateFloat(uint8_t v00, uint8_t v10, uint8_t v01,
60 uint8_t v11, float dx, float dy);
61
62} // namespace fl
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
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.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54