mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Fixed memory overwrite bug. This fixes the png writer and led control.
This commit is contained in:
@@ -20,6 +20,10 @@ add_executable(Test2BobLight
|
||||
target_link_libraries(Test2BobLight
|
||||
bob2hyperion)
|
||||
|
||||
add_executable(TestRgbImage
|
||||
TestRgbImage.cpp)
|
||||
target_link_libraries(TestRgbImage
|
||||
hyperion-utils)
|
||||
|
||||
# Find the libPNG
|
||||
find_package(PNG REQUIRED QUIET)
|
||||
@@ -27,11 +31,11 @@ find_package(PNG REQUIRED QUIET)
|
||||
# Add additional includes dirs
|
||||
include_directories(${PNG_INCLUDE_DIR})
|
||||
|
||||
if(PNG_FOUND)
|
||||
#if(PNG_FOUND)
|
||||
|
||||
add_executable(TestHyperionPng
|
||||
TestHyperionPng.cpp)
|
||||
|
||||
target_link_libraries(TestHyperionPng
|
||||
bob2hyperion-png)
|
||||
endif(PNG_FOUND)
|
||||
hyperion-png)
|
||||
#endif(PNG_FOUND)
|
||||
|
@@ -2,42 +2,44 @@
|
||||
// STL includes
|
||||
#include <iostream>
|
||||
|
||||
// Boblight includes
|
||||
#include <boblight.h>
|
||||
// HyperionPNG includes
|
||||
#include <hyperionpng/HyperionPng.h>
|
||||
|
||||
template <typename Hyperion_T>
|
||||
void process(Hyperion_T& hyperion)
|
||||
{
|
||||
hyperion.setInputSize(64, 64);
|
||||
|
||||
// Obtain reference to buffer
|
||||
RgbImage& image = hyperion.image();
|
||||
|
||||
// Write some data to the image
|
||||
std::cout << "Write data to buffer-image" << std::endl;
|
||||
for (unsigned y=0; y<image.height(); ++y)
|
||||
{
|
||||
for (unsigned x=0; x<image.width(); ++x)
|
||||
{
|
||||
const RgbColor color = {255, 0, 0};
|
||||
image(x,y) = color;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Commit image to write png" << std::endl;
|
||||
for (unsigned i=0; i<40; ++i)
|
||||
{
|
||||
// Commit the image (writing first png)
|
||||
hyperion.commit();
|
||||
}
|
||||
std::cout << "FINISHED" << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Initialisaing Boblight" << std::endl;
|
||||
void* blPng = boblight_init();
|
||||
// Construct instance of Hyperion-PNG
|
||||
std::cout << "Initialisaing Hyperion PNG" << std::endl;
|
||||
HyperionPng hyperion;
|
||||
|
||||
int width = 112;
|
||||
int height = 64;
|
||||
std::cout << "Defining scan range (" << width << "x" << height << ")" << std::endl;
|
||||
boblight_setscanrange(blPng, width, height);
|
||||
|
||||
int colorPtr[3];
|
||||
colorPtr[0] = 255;
|
||||
colorPtr[1] = 0;
|
||||
colorPtr[2] = 0;
|
||||
std::cout << "Using color [" << colorPtr[0] << "; " << colorPtr[1] << "; " << colorPtr[2] << "]" << std::endl;
|
||||
|
||||
int nrOfFrames = 150;
|
||||
std::cout << "Generating " << nrOfFrames << " frames" << std::endl;
|
||||
for (int iFrame=0; iFrame<nrOfFrames; ++iFrame)
|
||||
{
|
||||
for (int iWidth=0; iWidth<width; ++iWidth)
|
||||
{
|
||||
for (int iHeight=0; iHeight<height; ++iHeight)
|
||||
{
|
||||
boblight_addpixelxy(blPng, iWidth, iHeight, colorPtr);
|
||||
}
|
||||
}
|
||||
|
||||
boblight_sendrgb(blPng, 0, NULL);
|
||||
}
|
||||
|
||||
std::cout << "Destroying Boblight" << std::endl;
|
||||
boblight_destroy(blPng);
|
||||
process(hyperion);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
22
test/TestRgbImage.cpp
Normal file
22
test/TestRgbImage.cpp
Normal file
@@ -0,0 +1,22 @@
|
||||
|
||||
// Utils includes
|
||||
#include <utils/RgbImage.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
std::cout << "Constructing image" << std::endl;
|
||||
RgbImage image(64, 64, RgbColor::BLACK);
|
||||
|
||||
std::cout << "Writing image" << std::endl;
|
||||
for (unsigned y=0; y<64; ++y)
|
||||
{
|
||||
for (unsigned x=0; x<64; ++x)
|
||||
{
|
||||
image(x,y) = RgbColor::RED;
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Finished (destruction will be performed)" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user