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 "fl/stl/stdint.h"
8
9#include "fl/math/xymap.h"
10
11namespace fl {
12
20void upscaleArbitrary(const CRGB *input, CRGB *output, u16 inputWidth,
21 u16 inputHeight, const fl::XYMap& xyMap);
22
30void upscalePowerOf2(const CRGB *input, CRGB *output, u8 inputWidth,
31 u8 inputHeight, const fl::XYMap& xyMap);
32
41void upscaleRectangular(const CRGB *input, CRGB *output, u16 inputWidth,
42 u16 inputHeight, u16 outputWidth, u16 outputHeight);
43
52void upscaleRectangularPowerOf2(const CRGB *input, CRGB *output, u8 inputWidth,
53 u8 inputHeight, u8 outputWidth, u8 outputHeight);
54
55//
56inline void upscale(const CRGB *input, CRGB *output, u16 inputWidth,
57 u16 inputHeight, const fl::XYMap& xyMap) {
58 u16 outputWidth = xyMap.getWidth();
59 u16 outputHeight = xyMap.getHeight();
60 const bool wontFit =
61 (outputWidth != xyMap.getWidth() || outputHeight != xyMap.getHeight());
62
63 // Check if we can use the optimized rectangular version
64 const bool isRectangular = (xyMap.getType() == XYMap::kLineByLine);
65
66 if (isRectangular) {
67 // Use optimized rectangular version that bypasses XY mapping
68 if (wontFit || (inputWidth & (inputWidth - 1)) ||
69 (inputHeight & (inputHeight - 1))) {
70 upscaleRectangular(input, output, inputWidth, inputHeight,
71 outputWidth, outputHeight);
72 } else {
73 upscaleRectangularPowerOf2(input, output, inputWidth, inputHeight,
74 outputWidth, outputHeight);
75 }
76 } else {
77 // Use the original XY-mapped versions
78 if (wontFit || (inputWidth & (inputWidth - 1)) ||
79 (inputHeight & (inputHeight - 1))) {
80 upscaleArbitrary(input, output, inputWidth, inputHeight, xyMap);
81 } else {
82 upscalePowerOf2(input, output, inputWidth, inputHeight, xyMap);
83 }
84 }
85}
86
87// These are here for testing purposes and are slow. Their primary use
88// is to test against the fixed integer version above.
89void upscaleFloat(const CRGB *input, CRGB *output, u8 inputWidth,
90 u8 inputHeight, const fl::XYMap& xyMap);
91
92void upscaleArbitraryFloat(const CRGB *input, CRGB *output, u16 inputWidth,
93 u16 inputHeight, const fl::XYMap& xyMap);
94
95u8 upscaleFloat(u8 v00, u8 v10, u8 v01,
96 u8 v11, float dx, float dy);
97
98} // namespace fl
fl::XYMap xyMap
@ kLineByLine
Definition xymap.h:43
fl::CRGB CRGB
Definition crgb.h:25
unsigned char u8
Definition stdint.h:131
unsigned char u8
Definition stdint.h:131
void upscaleRectangular(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, u16 outputWidth, u16 outputHeight)
Optimized upscale for rectangular/line-by-line XY maps.
void upscaleRectangularPowerOf2(const CRGB *input, CRGB *output, u8 inputWidth, u8 inputHeight, u8 outputWidth, u8 outputHeight)
Optimized upscale for rectangular/line-by-line XY maps (power-of-2 version).
void upscaleArbitraryFloat(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, const XYMap &xyMap)
void upscaleArbitrary(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, const XYMap &xyMap)
Performs bilinear interpolation for upscaling an image.
u8 upscaleFloat(u8 v00, u8 v10, u8 v01, u8 v11, float dx, float dy)
void upscale(const CRGB *input, CRGB *output, u16 inputWidth, u16 inputHeight, const fl::XYMap &xyMap)
Definition upscale.h:56
void upscalePowerOf2(const CRGB *input, CRGB *output, u8 inputWidth, u8 inputHeight, const XYMap &xyMap)
Performs bilinear interpolation for upscaling an image.
Base definition for an LED controller.
Definition crgb.hpp:179
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38