-
-
Notifications
You must be signed in to change notification settings - Fork 257
NeoBitmapFile object API
NeoBitmapFile represents a image container object that retrieves pixels from a bmp file. The primary use of this class is to contain an image meta data and read from a file when it renders it to a NeoPixelBus.
There is a known issue with SPIFFS on ESP8266 and a workaround
This will define the object with the given Feature and File types.
Valid classes for FEATURE are the same as NeoPixelBus and you find them here.
Valid classes for FILE are any class that exposes the same API as the File
class. It does not require that it be the SDFile
.
NeoBitmapFile<NeoGrbFeature, File> image;
This will initialize the NeoBitmapFile to use the given file. It will check the contents of the file for a valid image and configure itself to read data from the file.
It will return false if the file is not a compatible file format. Currently it requires the file to be BMP, 24 or 32 bit, with no compression.
The file
instance passed in will be managed by the NeoBitmapFile object so there is no need to close it manually.
This will return the number of bytes a single pixel takes.
This will return the number of pixels in the file.
This will return the width in pixels of the file.
This will return the height in pixels of the file.
This will return the color of the given pixel.
- x - the horizontal pixel position.
- y - the vertical pixel position.
- <return>, a color object, RgbColor or RgbwColor.
void Blt(NeoBufferContext destBuffer, uint16_t indexPixel, int16_t xSrc, int16_t ySrc, int16_t wSrc)
Bit-aligned BLock Transfer.
This will transfer this image to the destBuffer at indexPixel. This is a linear transfer, not a 2D image rendering.
- destBuffer - Another NeoBuffer or NeoPixelBus.
- indexPixel - the location to start the render at.
- xSrc - the horizontal location in the bitmap to render from.
- ySrc - the vertical location in the bitmap to render from.
- wSrc - the number of pixels to render.
void Render<SHADER>(NeoBufferContext<T_COLOR_FEATURE> destBuffer, SHADER& shader, uint16_t indexPixel, int16_t xSrc, int16_t ySrc, int16_t wSrc)
This will render this image to the destBuffer at indexPixel using the given shader. This is a linear transfer, not a 2D image rendering.
- SHADER - a shader class type that matches the instance that will be passed
- destBuffer - Another NeoBuffer or NeoPixelBus.
- shader - A shader class instance that defines how each pixel is modified as it is transferred
- indexPixel - the location to start the render at.
- xSrc - the horizontal location in the bitmap to render from.
- ySrc - the vertical location in the bitmap to render from.
- wSrc - the number of pixels to render.
void Blt(NeoBufferContext destBuffer, int16_t xDest, int16_t yDest, int16_t xSrc, int16_t ySrc, int16_t wSrc, int16_t hSrc, LayoutMapCallback layoutMap)
Bit-aligned BLock Transfer.
This will transfer part of this image to the destBuffer at given location. This is a 2d image rendering.
- destBuffer - Another NeoBuffer or NeoPixelBus.
- xDest- the upper left location in the destination to render to
- yDest - the upper left location in the destination to render to
- xSrc - the upper left location in the source to render from
- ySrc - the upper left location in the source to render from
- wSrc - the width to render
- hSrc - the height to render
- layoutMap - a layoutMap callback that implements the destinations mapping routine (see below)
void Render<SHADER>(NeoBufferContext<T_COLOR_FEATURE> destBuffer, SHADER& shader, int16_t xDest, int16_t yDest, int16_t xSrc, int16_t ySrc, int16_t wSrc, int16_t hSrc, LayoutMapCallback layoutMap)
This will render part of this image to the destBuffer at given location using the provided shader. This is a 2d image rendering.
- SHADER - a shader class type that matches the instance that will be passed
- destBuffer - Another NeoBuffer or NeoPixelBus.
- shader - A shader class instance that defines how each pixel is modified as it is transferred
- xDest- the upper left location in the destination to render to
- yDest - the upper left location in the destination to render to
- xSrc - the upper left location in the source to render from
- ySrc - the upper left location in the source to render from
- wSrc - the width to render
- hSrc - the height to render
- layoutMap - a layoutMap callback that implements the destinations mapping routine (see below)
As the consumer of certain methods, you will need to implement this and pass it into those methods. You are expected to translate the x,y location of the destination to a linear index value. If you have implemented NeoTopology
, NeoTiles
, or NeoMosaic
; you can just call the MapProbe()
method on them and return what they provide.
NeoTopology<RowMajorLayout> topo(16,16); // 16x16 matrix panel
uint16_t MyLayoutMap(int16_t x, int16_t y)
{
return topo.MapProbe(x, y);
}
If you implement your own, make sure to handle out of range values beyond your edges including negative values and return PixelIndex_OutOfBounds
for these cases.