mirror of
https://github.com/Makuna/NeoPixelBus.git
synced 2025-08-07 04:44:26 +02:00
Updated NeoBuffer object (markdown)
@@ -25,9 +25,32 @@ NeoBuffer<NeoBuffermMethod<NeoGrbwFeature>> image(myImageWidth, myImageHeight, m
|
||||
NeoBuffer<NeoBufferProgmemMethod<NeoGrbwFeature>> image(myImageWidth, myImageHeight, myImage);
|
||||
```
|
||||
|
||||
## How to render the image to NeoPixelBus
|
||||
## How to render the image
|
||||
To render the buffer image you use one of the BLT (block transfer) methods. They will copy the image data from the buffer to the target.
|
||||
|
||||
### Targets of Rendering
|
||||
The BLT method all take a generic target for the first parameter of a `NeoBufferContext<>`. This buffer context is a mechanism to allow for different types of targets all can be used. You can pass the NeoPixelBus directly for this. You may also pass any of the other Raster objects that allow for writing to.
|
||||
|
||||
### Rendering to a string of pixels
|
||||
If you have both an image that is one pixel high, and you have just a string of pixels on your NeoPixelBus, and you want speed, then you can use `Blt(dest, destIndex)` method.
|
||||
If you have both an image that is one pixel high, and you have just a string of pixels on your NeoPixelBus, and you want speed, then you can use `Blt(dest, destIndex)` method. This method is limited but is very quick.
|
||||
|
||||
### Rendering to a matrix of pixels
|
||||
If your image has more than one row or column of pixels and/or your pixels are arranged in a matrix, then can use `Blt(dest, xDest, yDest, xSrc, ySrc, wSrc, hSrc, layoutMap)`.
|
||||
If your image has more than one row or column of pixels and/or your pixels are arranged in a matrix, then can use `Blt(dest, xDest, yDest, xSrc, ySrc, wSrc, hSrc, layoutMap)`. This is the most common way to render.
|
||||
|
||||
The complexity with this method is that the target buffer doesn't explicitly know how you have them laid out. Are you using NeoTopology or NeoMosaic? So you need to pass a callback as the "layoutMap" that will be called so you can provide the mapping. Inside this you can provide your custom layout mapping or you can use the `MapProbe()` method of any of the matrix panel support objects like NeoTopology, NeoTiles, or NeoMosaic.
|
||||
|
||||
```
|
||||
NeoTopology<RowMajorLayout> topo(16,16);
|
||||
|
||||
uint16_t LayoutMap(int16_t x, int16_t y)
|
||||
{
|
||||
return topo.MapProbe(x, y);
|
||||
}
|
||||
|
||||
```
|
||||
Once of you have defined this callback, then you can use to render parts of the image.
|
||||
```
|
||||
image.Blt(strip, 0, 0, 4, 4, 3, 4, LayoutMap);
|
||||
```
|
||||
This will render the image from location (0,0) to the strip at location (4,4) consisting of a rectangle of pixels that is 3 pixels wide and 4 pixels tall.
|
||||
|
||||
|
Reference in New Issue
Block a user