diff --git a/Makefile b/Makefile index 98d4dae485c7e0c041493b23975e75f3af0fd006..e4341553a647a0287abaecd8d4cb1a7c946f09cb 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ ## Makefile for mxgui ## This makefile builds libmxgui.a ## -MAKEFILE_VERSION := 1.07S +MAKEFILE_VERSION := 1.09S +GCCMAJOR := $(shell arm-miosix-eabi-gcc --version | \ + perl -e '$$_=<>;/\(GCC\) (\d+)/;print "$$1"') ## KPATH and CONFPATH are forwarded by the parent Makefile include $(CONFPATH)/config/Makefile.inc @@ -26,6 +28,7 @@ drivers/display_mp3v2.cpp \ drivers/event_mp3v2.cpp \ drivers/resfs_mp3v2.cpp \ drivers/display_strive.cpp \ +drivers/display_st7735.cpp \ drivers/display_oledboard2.cpp \ drivers/event_strive.cpp \ drivers/display_redbull_v2.cpp \ @@ -36,7 +39,8 @@ drivers/event_sony-newman.cpp \ drivers/display_stm32f4discovery.cpp \ drivers/event_stm32f4discovery.cpp \ drivers/display_generic_1bpp.cpp \ -drivers/display_generic_4bpp.cpp +drivers/display_generic_4bpp.cpp \ +drivers/display_st7735.cpp ifeq ("$(VERBOSE)","1") Q := diff --git a/_examples/benchmark/Makefile b/_examples/benchmark/Makefile index 9cad69363a4e9e42e7b634ab7bca6db93a7249df..389868fd14176693a4d8aec3da766ac14b59df01 100644 --- a/_examples/benchmark/Makefile +++ b/_examples/benchmark/Makefile @@ -1,7 +1,9 @@ ## ## Makefile for Miosix embedded OS ## -MAKEFILE_VERSION := 1.04 +MAKEFILE_VERSION := 1.09 +GCCMAJOR := $(shell arm-miosix-eabi-gcc --version | \ + perl -e '$$_=<>;/\(GCC\) (\d+)/;print "$$1"') ## Path to kernel directory (edited by init_project_out_of_git_repo.pl) KPATH := miosix ## Path to config directory (edited by init_project_out_of_git_repo.pl) @@ -33,6 +35,14 @@ INCLUDE_DIRS := -Imxgui ## You should not need to modify anything below ## ############################################################################## +ifeq ("$(VERBOSE)","1") +Q := +ECHO := @true +else +Q := @ +ECHO := @echo +endif + ## Replaces both "foo.cpp"-->"foo.o" and "foo.c"-->"foo.o" OBJ := $(addsuffix .o, $(basename $(SRC))) @@ -48,8 +58,14 @@ AFLAGS := $(AFLAGS_BASE) LFLAGS := $(LFLAGS_BASE) DFLAGS := -MMD -MP -LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group -lmiosix -lstdc++ -lc \ - -lm -lgcc -Wl,--end-group +## libmiosix.a is among stdlibs because needs to be within start/end group +STDLIBS := -lmiosix -lstdc++ -lc -lm -lgcc + +ifneq ($(GCCMAJOR),4) + STDLIBS += -latomic +endif + +LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group $(STDLIBS) -Wl,--end-group all: all-recursive main @@ -74,22 +90,27 @@ clean-topdir: -rm -f $(OBJ) main.elf main.hex main.bin main.map $(OBJ:.o=.d) main: main.elf - $(CP) -O ihex main.elf main.hex - $(CP) -O binary main.elf main.bin - $(SZ) main.elf + $(ECHO) "[CP ] main.hex" + $(Q)$(CP) -O ihex main.elf main.hex + $(ECHO) "[CP ] main.bin" + $(Q)$(CP) -O binary main.elf main.bin + $(Q)$(SZ) main.elf main.elf: $(OBJ) all-recursive - @ echo "linking" - $(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS) + $(ECHO) "[LD ] main.elf" + $(Q)$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS) %.o: %.s - $(AS) $(AFLAGS) $< -o $@ + $(ECHO) "[AS ] $<" + $(Q)$(AS) $(AFLAGS) $< -o $@ %.o : %.c - $(CC) $(DFLAGS) $(CFLAGS) $< -o $@ + $(ECHO) "[CC ] $<" + $(Q)$(CC) $(DFLAGS) $(CFLAGS) $< -o $@ %.o : %.cpp - $(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@ + $(ECHO) "[CXX ] $<" + $(Q)$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@ #pull in dependecy info for existing .o files -include $(OBJ:.o=.d) diff --git a/_examples/benchmark/benchmark.cpp b/_examples/benchmark/benchmark.cpp index 0eef9fa13528a0eba05a9e01df3de31ce85d1a5c..c9fe422c87f56a5905e9f0a1a34a300b8109871e 100644 --- a/_examples/benchmark/benchmark.cpp +++ b/_examples/benchmark/benchmark.cpp @@ -33,8 +33,10 @@ #include "benchmark.h" #include <cstdio> #include <cstring> +#include <chrono> using namespace std; +using namespace std::chrono; using namespace mxgui; using namespace miosix; @@ -155,14 +157,13 @@ void Benchmark::fixedWidthTextBenchmark() i%2==0 ? dc.setTextColor(white,black) : dc.setTextColor(black,white); #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR } - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getHeight();j+=16) dc.write(Point(0,j),text); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -192,14 +193,13 @@ void Benchmark::variableWidthTextBenchmark() i%2==0 ? dc.setTextColor(white,black) : dc.setTextColor(black,white); #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR } - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getHeight();j+=12) dc.write(Point(0,j),text); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -226,14 +226,13 @@ void Benchmark::antialiasingBenchmark() dc.setFont(droid11); dc.setTextColor(i%2==0 ? red : green,black); } - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getHeight();j+=12) dc.write(Point(0,j),text); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -251,15 +250,14 @@ void Benchmark::horizontalLineBenchmark() #else //MXGUI_COLOR_DEPTH_1_BIT_LINEAR Color color=i%2==0?white:black; #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getHeight();j++) dc.line(Point(0,j),Point(dc.getWidth()-1,j),color); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -276,15 +274,14 @@ void Benchmark::verticalLineBenchmark() #else //MXGUI_COLOR_DEPTH_1_BIT_LINEAR Color color=i%2==0?white:black; #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getWidth();j++) dc.line(Point(j,0),Point(j,dc.getHeight()-1),color); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -308,7 +305,7 @@ void Benchmark::obliqueLineBenchmark() Color colorB=colorA; Color colorC=i%2==0?black:white; #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); if(dc.getHeight()>=dc.getWidth()) @@ -346,9 +343,8 @@ void Benchmark::obliqueLineBenchmark() } } } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -365,14 +361,13 @@ void Benchmark::clearScreenBenchmark() #else //MXGUI_COLOR_DEPTH_1_BIT_LINEAR Color color=i%2==0?white:black; #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); dc.clear(color); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -384,7 +379,7 @@ void Benchmark::imageBenchmark() unsigned int totalTime=0; for(int i=0;i<4;i++) { - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getWidth();j+=16) @@ -395,14 +390,13 @@ void Benchmark::imageBenchmark() dc.drawImage(Point(j,k),checkpattern2); #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR } - timer.stop(); + auto d=system_clock::now()-t; delayMs(250); { DrawingContext dc(display); dc.clear(black); } - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + totalTime+=duration_cast<microseconds>(d).count(); delayMs(250); } totalTime/=4; @@ -448,16 +442,15 @@ void Benchmark::scanLineBenchmark() unsigned int totalTime=0; for(int i=0;i<4;i++) { - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); //TODO: does not work well for displays with width > 240 for(int k=0;k<dc.getHeight();k++) dc.scanLine(Point(0,k),rainbow,min<int>(240,dc.getWidth())); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(250); { DrawingContext dc(display); @@ -475,7 +468,7 @@ void Benchmark::clippedDrawBenchmark() unsigned int totalTime=0; for(int i=0;i<4;i++) { - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getWidth();j+=8) @@ -491,14 +484,13 @@ void Benchmark::clippedDrawBenchmark() #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR } } - timer.stop(); + auto d=system_clock::now()-t; delayMs(250); { DrawingContext dc(display); dc.clear(black); } - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + totalTime+=duration_cast<microseconds>(d).count(); delayMs(250); } totalTime/=4; @@ -530,7 +522,7 @@ void Benchmark::clippedWriteBenchmark() else dc.setTextColor(black,white); #endif //MXGUI_COLOR_DEPTH_1_BIT_LINEAR } - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); for(int j=0;j<dc.getHeight();j+=6) @@ -541,9 +533,8 @@ void Benchmark::clippedWriteBenchmark() dc.clippedWrite(p,a,b,text); } } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; @@ -562,14 +553,13 @@ void Benchmark::resourceImageBenchmark() DrawingContext dc(display); dc.clear(black); } - timer.start(); + auto t=system_clock::now(); { DrawingContext dc(display); dc.drawImage(Point(0,0),img); } - timer.stop(); - totalTime+=timer.interval()*1000000/TICK_FREQ; - timer.clear(); + auto d=system_clock::now()-t; + totalTime+=duration_cast<microseconds>(d).count(); delayMs(500); } totalTime/=4; diff --git a/_examples/benchmark/benchmark.h b/_examples/benchmark/benchmark.h index ba204cbc086d65494e575b0c7262724f2299878e..5f12a2dcfe539917b1595dce66a7a34572d713c7 100644 --- a/_examples/benchmark/benchmark.h +++ b/_examples/benchmark/benchmark.h @@ -122,7 +122,6 @@ private: mxgui::Display& display; BenchmarkResult results[numBenchmarks]; int index; - miosix::Timer timer; }; #endif //_MIOSIX diff --git a/_examples/benchmark/checkpattern2.cpp b/_examples/benchmark/checkpattern2.cpp new file mode 100644 index 0000000000000000000000000000000000000000..fe484cf729c573893ac55d15c39abc94814bed61 --- /dev/null +++ b/_examples/benchmark/checkpattern2.cpp @@ -0,0 +1,16 @@ + +//This file has been automatcally generated by pngconverter utility +//Please do not edit +#include "checkpattern2.h" + +using namespace mxgui; + +static const short int height=16; +static const short int width =16; + +static const unsigned char pixelData[]={ + 88,0,175,254,215,254,43,230,53,230,58,254,61,126,50,190, + 51,94,51,174,51,214,51,43,51,53,51,58,51,61,51,50 +}; + +const basic_image<Color1bitlinear> checkpattern2(height,width,pixelData); \ No newline at end of file diff --git a/_examples/benchmark/checkpattern2.h b/_examples/benchmark/checkpattern2.h new file mode 100644 index 0000000000000000000000000000000000000000..3a8d7a503d30c5c842b1b87494e7971ea202f019 --- /dev/null +++ b/_examples/benchmark/checkpattern2.h @@ -0,0 +1,11 @@ + +//This file has been automatcally generated by pngconverter utility +//Please do not edit +#ifndef CHECKPATTERN2_H +#define CHECKPATTERN2_H + +#include "mxgui/image.h" + +extern const mxgui::Image checkpattern2; + +#endif //CHECKPATTERN2_H diff --git a/_examples/display_st7735/main.cpp b/_examples/display_st7735/main.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f8a561aafa9761c8fbe9277cec732203c7660fa6 --- /dev/null +++ b/_examples/display_st7735/main.cpp @@ -0,0 +1,21 @@ +#include <cstdio> +#include "miosix.h" +#include "mxgui/display.h" +#include "mxgui/misc_inst.h" + +using namespace std; +using namespace miosix; +using namespace mxgui; + +int main() +{ + auto& display=DisplayManager::instance().getDisplay(); + { + DrawingContext dc(display); + dc.setFont(droid21); + dc.write(Point(0,0),"Miosix OS"); + dc.setFont(tahoma); + dc.write(Point(0,droid21.getHeight()),"MXGUI graphics library"); + } + for(;;) Thread::sleep(100); +} diff --git a/_examples/display_st7735/retargeted-display.cpp b/_examples/display_st7735/retargeted-display.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b245cbae17a68aa0d37cdb44ee9107d5731a0722 --- /dev/null +++ b/_examples/display_st7735/retargeted-display.cpp @@ -0,0 +1,101 @@ + +#include "miosix.h" +#include "mxgui/drivers/display_st7735.h" + +#ifndef _BOARD_STM32F4DISCOVERY +#warning "This SPI driver has only been tested on an STM32F4DISCOVERY" +#endif //_BOARD_STM32F4DISCOVERY + +using namespace miosix; +using namespace mxgui; + +//Hardware mapping +using scl = Gpio<GPIOB_BASE, 13>; //PB13, SPI1_SCK (af5) +using sda = Gpio<GPIOB_BASE, 15>; //PB15, SPI1_MOSI (af5) +using csx = Gpio<GPIOB_BASE, 4>; //PB4, free I/O pin +using dcx = Gpio<GPIOA_BASE, 8>; //PA8, free I/O pin, used only in 4-line SPI +using resx = Gpio<GPIOC_BASE, 6>; //PC6, free I/O pin + +/** + * Non-abstract class retargeting DisplayGenericST7735 to the correct + * GPIOs and SPI peripheral + */ +class MyDisplay : public DisplayGenericST7735 +{ +public: + static MyDisplay& instance() + { + static MyDisplay singleton; + return singleton; + } + +private: + MyDisplay() : DisplayGenericST7735(csx::getPin(),dcx::getPin(),resx::getPin()) + { + { + FastInterruptDisableLock dLock; + + RCC->APB1ENR |= RCC_APB1ENR_SPI2EN; + SPI2->CR1 = 0; + SPI2->CR1 = SPI_CR1_SSM //Software cs + | SPI_CR1_SSI //Hardware cs internally tied high + | SPI_CR1_BR_0 //clock divider: 4 -> 10,5 MHz -> 95 ns + | SPI_CR1_MSTR //Master mode + | SPI_CR1_SPE; //SPI enabled + + scl::mode(Mode::ALTERNATE); scl::alternateFunction(5); + sda::mode(Mode::ALTERNATE); sda::alternateFunction(5); + // GPIO software controlled + csx.mode(Mode::OUTPUT); + dcx.mode(Mode::OUTPUT); + resx.mode(Mode::OUTPUT); + } + initialize(); + } + + unsigned char writeRam(unsigned char data) override + { + SPI2->DR = data; + while((SPI2->SR & SPI_SR_RXNE) == 0) ; + return SPI2->DR; //Note: reading back SPI2->DR is necessary. + } + + void writeReg(unsigned char reg, unsigned char data) override + { + Transaction t(csx); + { + Transaction c(dcx); + writeRam(reg); + } + writeRam(data); + } + + void writeReg(unsigned char reg, const unsigned char *data=0, int len=1) override + { + Transaction t(csx); + { + Transaction c(dcx); + writeRam(reg); + } + if(data) for(int i = 0; i < len; i++) writeRam(*data++); + } +}; + +/* + * On boards which do not have a built-in display, MXGUI requires you to + * implement the registerDisplayHook callback to tell MXGUI which display to + * use. If you want to adapt this example for a board that already has a + * display, you can register a secondary display in the main with the following + * line + * \code + * DisplayManager::instance().registerDisplay(new DisplayLy091wg14<sda,scl,reset>); + * \endcode + * And then get the display with DisplayManager::instance().getDisplay(1). + * Note that 0 is the default display, 1 would be the secondary one. + */ +namespace mxgui { +void registerDisplayHook(DisplayManager& dm) +{ + dm.registerDisplay(&MyDisplay::instance()); +} +} //namespace mxgui diff --git a/_tools/code_generators/CMakeLists.txt b/_tools/code_generators/CMakeLists.txt index cb2ac65e17c24994898a8bbd7d9ef27989b0059b..5a2baa3a04a25d049a095d59cbf153310f784206 100644 --- a/_tools/code_generators/CMakeLists.txt +++ b/_tools/code_generators/CMakeLists.txt @@ -40,8 +40,8 @@ target_link_libraries(resourcefs ${Boost_LIBRARIES}) #include_directories(${FREETYPE_INCLUDE_DIRS}) #target_link_libraries(fontrendering ${FREETYPE_LIBRARIES}) ## Uncomment this if you want to build and use freetype 2.4.3 -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/build/freetype-2.4.3/include) -find_library(FREETYPE NAMES freetype HINTS ${CMAKE_CURRENT_SOURCE_DIR}/build/freetype-2.4.3/objs/.libs) +include_directories(${CMAKE_CURRENT_BINARY_DIR}/freetype-2.4.3/include) +find_library(FREETYPE NAMES freetype HINTS ${CMAKE_CURRENT_BINARY_DIR}/freetype-2.4.3/objs/.libs) target_link_libraries(fontrendering ${FREETYPE}) find_package(ZLIB REQUIRED) diff --git a/_tools/code_generators/libs/png++/ChangeLog b/_tools/code_generators/libs/png++/ChangeLog index ca3792187264a18d414072316b15aa153b0eb38d..e4433a94a837ad58cbd49d4a046e735deaba6962 100644 --- a/_tools/code_generators/libs/png++/ChangeLog +++ b/_tools/code_generators/libs/png++/ChangeLog @@ -1,3 +1,8 @@ +2009-06-21 Alex Shulgin + + * config.hpp: Added support for FreeBSD (detect endianness). + Patch by <c.petrik.sosa@gmail.com>. + png++-0.2.3 19 Oct 2008 Fixed numerous `already defined' errors due to require_color_space diff --git a/_tools/code_generators/libs/png++/Doxyfile b/_tools/code_generators/libs/png++/Doxyfile index 0db262f0470adc22bc3fd1ba4d749b5b8072562d..0692826bf28bd8523bb696ea4ba35a1af62f64f9 100644 --- a/_tools/code_generators/libs/png++/Doxyfile +++ b/_tools/code_generators/libs/png++/Doxyfile @@ -29,7 +29,7 @@ PROJECT_NAME = png++ # number. This could be handy for archiving the generated # documentation or if some version control system is used. -PROJECT_NUMBER = 0.2.1 +PROJECT_NUMBER = $(VERSION) # The OUTPUT_DIRECTORY tag is used to specify the (relative or # absolute) base path where the generated documentation will be put. diff --git a/_tools/code_generators/libs/png++/Makefile b/_tools/code_generators/libs/png++/Makefile index 2accfbec969807c465e3dbb455ec7fe8f79a17bd..3cc0a11902d6e66f072070b0cd63be1cc7b6f5ef 100644 --- a/_tools/code_generators/libs/png++/Makefile +++ b/_tools/code_generators/libs/png++/Makefile @@ -29,34 +29,18 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -# don't forget to update version before releasing! -version := 0.2.3 - -ifndef PREFIX -PREFIX := /usr/local -endif - -ifdef MINGW -bin_suffix := .exe -endif +PNGPP := . -make_cflags := -Wall $(CFLAGS) -I$(PREFIX)/include -make_ldflags := $(LDFLAGS) -L$(PREFIX)/lib - -ifndef NDEBUG -make_cflags := $(make_cflags) -g -make_ldflags := $(make_ldflags) -g -endif - -ifndef LIBPNG_CONFIG -LIBPNG_CONFIG := libpng-config -endif +# don't forget to update version before releasing! +version := 0.2.9 -build_files := Makefile Doxyfile +build_files := common.mk Makefile Doxyfile doc_files := AUTHORS BUGS ChangeLog COPYING INSTALL NEWS README TODO -headers := *.hpp +headers := $(wildcard *.hpp) sources := +include common.mk + dist_dir := png++-$(version) dist_package := png++-$(version).tar.gz dist_files := $(build_files) $(doc_files) \ @@ -67,9 +51,14 @@ all: examples install: install-headers install-docs +uninstall: uninstall-headers uninstall-docs + install-headers: mkdir -p $(PREFIX)/include/png++ - cp *.hpp $(PREFIX)/include/png++ + cp $(headers) $(PREFIX)/include/png++ + +uninstall-headers: + rm -rf $(PREFIX)/include/png++ dist: dist-mkdir dist-copy-files dist-package @@ -90,27 +79,24 @@ dist-package: rm -rf $(dist_dir) clean: test-clean examples-clean -# rm -f $(targets) thorough-clean: clean docs-clean check: test test: - $(MAKE) test -C test $(MAKEFLAGS) PNGPP=`pwd` + $(MAKE) test -C test $(MAKEFLAGS) test-clean: $(MAKE) clean -C test $(MAKEFLAGS) -test-compile-headers: *.hpp - for i in *.hpp; do \ - echo '#include "'$$i'"' >$$i.cpp \ - && g++ -c $$i.cpp $(make_cflags) `$(LIBPNG_CONFIG) --cflags`; \ - done - rm -f *.hpp.o *.hpp.cpp +test-compile-headers: $(headers:%.hpp=%.hpp.o) + +%.hpp.o: + $(CXX) -c $(@:%.hpp.o=%.hpp) -o /dev/null $(make_cflags) docs: - doxygen + VERSION=$(version) doxygen docs-clean: rm -rf doc @@ -126,15 +112,18 @@ install-docs: [ -d png++ ] || ln -s $(dist_dir) png++; \ fi +uninstall-docs: + rm -rf $(PREFIX)/share/doc/$(dist_dir) $(PREFIX)/share/doc/png++ + examples: $(MAKE) -C example $(MAKEFLAGS) examples-clean: $(MAKE) clean -C example $(MAKEFLAGS) -.PHONY: all install \ +.PHONY: install \ dist dist-mkdir dist-copy-files dist-package \ - clean thorough-clean \ + thorough-clean \ check test test-clean test-compile-headers \ docs docs-clean \ examples examples-clean diff --git a/_tools/code_generators/libs/png++/NEWS b/_tools/code_generators/libs/png++/NEWS index 74b228b9f04d1fa065e82945aa63f18daa3db075..cc006fbf5eb5ddf9c1c0008b0cdfee38ac812f8e 100644 --- a/_tools/code_generators/libs/png++/NEWS +++ b/_tools/code_generators/libs/png++/NEWS @@ -1,3 +1,21 @@ +Version 0.2.7: + + - Added solid_pixel_buffer (patch by Andrey Potapov). + + - Fixed some compilation problems on Win32. + +Version 0.2.5: + + - Fixed compatibility with newer libpng versions (>= 1.4) + + - Fixed compilation on FreeBSD. + + - Fixed tRNS handling with transformations. + + - Added IO transformation debugging facility. + + - Better organized test suite. + Version 0.2.3: - Fixed numerous `already defined' errors due to require_color_space diff --git a/_tools/code_generators/libs/png++/common.mk b/_tools/code_generators/libs/png++/common.mk new file mode 100644 index 0000000000000000000000000000000000000000..2886324d80cd629a1ff9686ced0fbf933bc8b700 --- /dev/null +++ b/_tools/code_generators/libs/png++/common.mk @@ -0,0 +1,47 @@ +ifndef PREFIX +PREFIX := /usr/local +endif + +ifdef MINGW +bin_suffix := .exe +endif + +ifndef CXX +CXX := g++ +endif + +ifndef LIBPNG_CONFIG +LIBPNG_CONFIG := libpng-config +endif + +make_cflags := -Wall -I$(PNGPP) -I$(PREFIX)/include $(shell $(LIBPNG_CONFIG) --cflags) $(CFLAGS) +make_ldflags := -L$(PREFIX)/lib $(shell $(LIBPNG_CONFIG) --ldflags) $(LDFLAGS) + +ifndef NDEBUG +make_cflags := $(make_cflags) -g +make_ldflags := $(make_ldflags) -g +endif + +deps := $(sources:.cpp=.dep) +objects := $(sources:.cpp=.o) +bins := $(sources:.cpp=$(bin_suffix)) + +all: $(deps) $(bins) + +%$(bin_suffix): %.o + $(CXX) -o $@ $< $(make_ldflags) + +%.o: %.cpp + $(CXX) -c -o $@ $< $(make_cflags) + +%.dep: %.cpp + $(CXX) -M $(CPPFLAGS) $(make_cflags) $< -o- | \ + sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@ + +clean: clean-deps + rm -f $(bins) $(objects) + +clean-deps: + rm -f $(deps) + +.PHONY: all clean clean-deps diff --git a/_tools/code_generators/libs/png++/config.hpp b/_tools/code_generators/libs/png++/config.hpp index 0604e42ca3d4e6f1cd0c1302c562bc2fc322e3ae..4a317b29cfa564356209bd4956648ddcf5415b34 100644 --- a/_tools/code_generators/libs/png++/config.hpp +++ b/_tools/code_generators/libs/png++/config.hpp @@ -31,12 +31,14 @@ #ifndef PNGPP_CONFIG_HPP_INCLUDED #define PNGPP_CONFIG_HPP_INCLUDED +#include <stdlib.h> + // Endianness test #if defined(__GLIBC__) #include <endian.h> -#elif defined(__WIN32) +#elif defined(_WIN32) #define __LITTLE_ENDIAN 1234 #define __BIG_ENDIAN 4321 @@ -47,10 +49,50 @@ #include <machine/endian.h> #include <sys/_endian.h> +#elif defined(__FreeBSD__) + +#include <machine/endian.h> +#include <sys/endian.h> + +#elif defined(__sun) + +#include <sys/isa_defs.h> + #else #error Byte-order could not be detected. #endif +// Determine C++11 features +#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) && defined(__GXX_EXPERIMENTAL_CXX0X__) + +#define PNGPP_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) +// gcc c++11 support list +// http://gcc.gnu.org/projects/cxx0x.html + +// gcc supports static_assert since 4.3 +#if (PNGPP_GCC_VERSION >= 40300) +#define PNGPP_HAS_STATIC_ASSERT +#endif + +// gcc supports std::move since 4.6 +#if (PNGPP_GCC_VERSION >= 40600) +#define PNGPP_HAS_STD_MOVE +#endif + +#undef PNGPP_GCC_VERSION + +#elif defined(_MSC_VER) + +// MS Visual C++ compiler supports static_assert and std::move since VS2010 +// http://blogs.msdn.com/b/vcblog/archive/2011/09/12/10209291.aspx +#if (_MSC_VER >= 1600) +#define PNGPP_HAS_STATIC_ASSERT +#define PNGPP_HAS_STD_MOVE +#endif + +#endif + + #endif // PNGPP_CONFIG_HPP_INCLUDED diff --git a/_tools/code_generators/libs/png++/consumer.hpp b/_tools/code_generators/libs/png++/consumer.hpp index dac63746f8248dfd0ff8c7c0ded73446f864aa16..a3ff9ecc97213f8a7dcd97bc318fb3026a3d40c5 100644 --- a/_tools/code_generators/libs/png++/consumer.hpp +++ b/_tools/code_generators/libs/png++/consumer.hpp @@ -68,7 +68,7 @@ namespace png * as follows: * * \code - * png::byte* get_next_row(size_t pos); + * png::byte* get_next_row(png::uint_32 pos); * void reset(size_t pass); * \endcode * @@ -167,8 +167,7 @@ namespace png #ifdef PNG_READ_SWAP_SUPPORTED rd.set_swap(); #else - throw error("Cannot read 16-bit image:" - " recompile with PNG_READ_SWAP_SUPPORTED."); + throw error("Cannot read 16-bit image: recompile with PNG_READ_SWAP_SUPPORTED."); #endif } #endif @@ -180,8 +179,7 @@ namespace png #ifdef PNG_READ_INTERLACING_SUPPORTED pass_count = rd.set_interlace_handling(); #else - throw error("Cannot read interlaced image:" - " interlace handling disabled."); + throw error("Cannot read interlaced image: interlace handling disabled."); #endif } else @@ -244,7 +242,7 @@ namespace png { pixel_con->reset(pass); - for (size_t pos = 0; pos < this->get_info().get_height(); ++pos) + for (uint_32 pos = 0; pos < this->get_info().get_height(); ++pos) { rd.read_row(pixel_con->get_next_row(pos)); } diff --git a/_tools/code_generators/libs/png++/convert_color_space.hpp b/_tools/code_generators/libs/png++/convert_color_space.hpp index 796a903980f1dfca3cf3d018eba411e161b216c0..19b25432f701b997d5bd88911a28d8d540fcd218 100644 --- a/_tools/code_generators/libs/png++/convert_color_space.hpp +++ b/_tools/code_generators/libs/png++/convert_color_space.hpp @@ -74,26 +74,34 @@ namespace png static void expand_8_to_16(png_struct*, png_row_info* row_info, byte* row) { -// dump_row(row, row_info->rowbytes); - - for (size_t i = row_info->rowbytes; i-- > 0; ) +#ifdef DEBUG_EXPAND_8_16 + printf("row: width=%d, bytes=%d, channels=%d\n", + row_info->width, row_info->rowbytes, row_info->channels); + printf("<= "); + dump_row(row, row_info->rowbytes); +#endif + for (uint_32 i = row_info->rowbytes; i-- > 0; ) { - row[i*2 + 1] = row[i]; - row[i*2 + 0] = 0; + row[2*i + 1] = row[i]; + row[2*i + 0] = 0; } - -// dump_row(row, 2*row_info->rowbytes); +#ifdef DEBUG_EXPAND_8_16 + printf("=> "); + dump_row(row, 2*row_info->rowbytes); +#endif } - static void dump_row(byte const* row, size_t width) +#ifdef DEBUG_EXPAND_8_16 + static void dump_row(byte const* row, uint_32 width) { printf("{"); - for (size_t i = 0; i < width; ++i) + for (uint_32 i = 0; i < width; ++i) { printf(" %02x,", row[i]); } printf(" }\n"); } +#endif template< class reader > static void handle_16(reader& io) @@ -103,8 +111,7 @@ namespace png #ifdef PNG_READ_16_TO_8_SUPPORTED io.set_strip_16(); #else - throw error("expected 8-bit data but found 16-bit;" - " recompile with PNG_READ_16_TO_8_SUPPORTED"); + throw error("expected 8-bit data but found 16-bit; recompile with PNG_READ_16_TO_8_SUPPORTED"); #endif } if (io.get_bit_depth() != 16 && traits::get_bit_depth() == 16) @@ -114,9 +121,7 @@ namespace png io.set_user_transform_info(NULL, 16, traits::get_channels()); #else - throw error("expected 16-bit data but found 8-bit;" - " recompile with" - " PNG_READ_USER_TRANSFORM_SUPPORTED"); + throw error("expected 16-bit data but found 8-bit; recompile with PNG_READ_USER_TRANSFORM_SUPPORTED"); #endif } } @@ -124,23 +129,21 @@ namespace png template< class reader > static void handle_alpha(reader& io, uint_32 filler) { - bool src_alpha = io.get_color_type() & color_mask_alpha; + bool src_alpha = (io.get_color_type() & color_mask_alpha); + bool src_tRNS = io.has_chunk(chunk_tRNS); bool dst_alpha = traits::get_color_type() & color_mask_alpha; - if (src_alpha && !dst_alpha) + if ((src_alpha || src_tRNS) && !dst_alpha) { #ifdef PNG_READ_STRIP_ALPHA_SUPPORTED io.set_strip_alpha(); #else - throw error("alpha channel unexpected;" - " recompile with" - " PNG_READ_STRIP_ALPHA_SUPPORTED"); + throw error("alpha channel unexpected; recompile with PNG_READ_STRIP_ALPHA_SUPPORTED"); #endif } if (!src_alpha && dst_alpha) { #if defined(PNG_tRNS_SUPPORTED) && defined(PNG_READ_EXPAND_SUPPORTED) - if ((io.get_color_type() & color_mask_palette) - && io.has_chunk(chunk_tRNS)) + if (src_tRNS) { io.set_tRNS_to_alpha(); return; @@ -149,9 +152,7 @@ namespace png #if defined(PNG_READ_FILLER_SUPPORTED) && !defined(PNG_1_0_X) io.set_add_alpha(filler, filler_after); #else - throw error("expected alpha channel but none found;" - " recompile with PNG_READ_FILLER_SUPPORTED" - " and be sure to use libpng > 1.0.x"); + throw error("expected alpha channel but none found; recompile with PNG_READ_FILLER_SUPPORTED and be sure to use libpng > 1.0.x"); #endif } } @@ -159,19 +160,36 @@ namespace png template< class reader > static void handle_palette(reader& io) { - if (io.get_color_type() == color_type_palette) + bool src_palette = + io.get_color_type() == color_type_palette; + bool dst_palette = + traits::get_color_type() == color_type_palette; + if (src_palette && !dst_palette) { #ifdef PNG_READ_EXPAND_SUPPORTED io.set_palette_to_rgb(); - - if (traits::get_color_type() != color_type_palette) - { - io.get_info().drop_palette(); - } + io.get_info().drop_palette(); #else - throw error("indexed colors unexpected;" - " recompile with PNG_READ_EXPAND_SUPPORTED"); + throw error("indexed colors unexpected; recompile with PNG_READ_EXPAND_SUPPORTED"); +#endif + } + else if (!src_palette && dst_palette) + { + throw error("conversion to indexed colors is unsupported (yet)"); + } + else if (src_palette && dst_palette + && io.get_bit_depth() != traits::get_bit_depth()) + { + if (traits::get_bit_depth() == 8) + { +#ifdef PNG_READ_PACK_SUPPORTED + io.set_packing(); #endif + } + else + { + throw error("cannot convert to indexed colors with bit-depth < 8"); + } } } @@ -186,9 +204,7 @@ namespace png #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED io.set_rgb_to_gray(/*rgb_to_gray_error*/); #else - throw error("grayscale data expected;" - " recompile with" - " PNG_READ_RGB_TO_GRAY_SUPPORTED"); + throw error("grayscale data expected; recompile with PNG_READ_RGB_TO_GRAY_SUPPORTED"); #endif } if (!src_rgb && dst_rgb) @@ -196,9 +212,7 @@ namespace png #ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED io.set_gray_to_rgb(); #else - throw error("expected RGB data;" - " recompile with" - " PNG_READ_GRAY_TO_RGB_SUPPORTED"); + throw error("expected RGB data; recompile with PNG_READ_GRAY_TO_RGB_SUPPORTED"); #endif } } @@ -214,9 +228,7 @@ namespace png #ifdef PNG_READ_EXPAND_SUPPORTED io.set_gray_1_2_4_to_8(); #else - throw error("convert_color_space: expected 8-bit data;" - " recompile with" - " PNG_READ_EXPAND_SUPPORTED"); + throw error("convert_color_space: expected 8-bit data; recompile with PNG_READ_EXPAND_SUPPORTED"); #endif } } @@ -325,6 +337,16 @@ namespace png { }; + /** + * \brief Converts %image %color space. A specialization for + * index_pixel type. + */ + template<> + struct convert_color_space< index_pixel > + : detail::convert_color_space_impl< index_pixel > + { + }; + } // namespace png #endif // PNGPP_CONVERT_COLOR_SPACE_HPP_INCLUDED diff --git a/_tools/code_generators/libs/png++/error.hpp b/_tools/code_generators/libs/png++/error.hpp index 971032f310454d9fd3bdc9bf308379f6240e7a56..834cf1b3a9e84997b21ec685f7e401cc9810964b 100644 --- a/_tools/code_generators/libs/png++/error.hpp +++ b/_tools/code_generators/libs/png++/error.hpp @@ -31,9 +31,21 @@ #ifndef PNGPP_ERROR_HPP_INCLUDED #define PNGPP_ERROR_HPP_INCLUDED +/* check if we have strerror_s or strerror_r, prefer the former which is C11 std */ +#ifdef __STDC_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 +#include <string.h> + +#define HAVE_STRERROR_S 1 +#else +#undef HAVE_STRERROR_S +#endif + +#include <string> #include <stdexcept> #include <cerrno> #include <cstdlib> +#include <cstring> namespace png { @@ -73,10 +85,32 @@ namespace png * \param message error description * \param error error number */ - explicit std_error(std::string const& message, int error = errno) - : std::runtime_error((message + ": ") + strerror(error)) + explicit std_error(std::string const& message, int errnum = errno) + : std::runtime_error((message + ": ") + thread_safe_strerror(errnum)) { } + + protected: + static std::string thread_safe_strerror(int errnum) + { +#define ERRBUF_SIZE 512 + char buf[ERRBUF_SIZE] = { 0 }; + +#ifdef HAVE_STRERROR_S + strerror_s(buf, ERRBUF_SIZE, errnum); + return std::string(buf); +#else +#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE + strerror_r(errnum, buf, ERRBUF_SIZE); + return std::string(buf); +#else + /* GNU variant can return a pointer to static buffer instead of buf */ + return std::string(strerror_r(errnum, buf, ERRBUF_SIZE)); +#endif +#endif + +#undef ERRBUF_SIZE + } }; } // namespace png diff --git a/_tools/code_generators/libs/png++/example/Makefile b/_tools/code_generators/libs/png++/example/Makefile index 1cbb0a2f4f4bc6e63850952dcaa4edd10e1ddaab..3c209dc0c58d7d2f989584ceee8a563d1293ba6d 100644 --- a/_tools/code_generators/libs/png++/example/Makefile +++ b/_tools/code_generators/libs/png++/example/Makefile @@ -28,55 +28,18 @@ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -ifndef PREFIX -PREFIX := /usr/local -endif - ifndef PNGPP PNGPP := .. endif -make_cflags := -Wall $(CFLAGS) -I$(PREFIX)/include -I$(PNGPP) -make_ldflags := $(LDFLAGS) -L$(PREFIX)/lib - -ifndef NDEBUG -make_cflags := $(make_cflags) -g -make_ldflags := $(make_ldflags) -g -endif - -ifndef LIBPNG_CONFIG -LIBPNG_CONFIG := libpng-config -endif - sources := pixel_generator.cpp -deps := $(sources:.cpp=.dep) -objects := $(sources:.cpp=.o) -targets := $(sources:.cpp=$(bin_suffix)) - -all: $(deps) $(targets) +include ../common.mk dist-copy-files: mkdir $(dist_dir)/example cp $(sources) Makefile $(dist_dir)/example -clean: clean-deps - rm -f $(targets) $(objects) - -.PHONY: all dist-copy-files clean clean-deps - -%$(bin_suffix): %.o - g++ -o $@ $< $(make_ldflags) `$(LIBPNG_CONFIG) --ldflags` - -%.o: %.cpp - g++ -c -o $@ $< $(make_cflags) `$(LIBPNG_CONFIG) --cflags` - - -%.dep: %.cpp - g++ -M $(CPPFLAGS) $(make_cflags) $< -o- | \ - sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@ - -clean-deps: - rm -f $(deps) +.PHONY: dist-copy-files include $(deps) diff --git a/_tools/code_generators/libs/png++/generator.hpp b/_tools/code_generators/libs/png++/generator.hpp index e9cc02be01f5bc5b6b0d4ad7fd7872acb708ef5a..e2f632319e6b77924de0577abdd8db431fe1dc2c 100644 --- a/_tools/code_generators/libs/png++/generator.hpp +++ b/_tools/code_generators/libs/png++/generator.hpp @@ -69,7 +69,7 @@ namespace png * as follows: * * \code - * png::byte* get_next_row(size_t pos); + * png::byte* get_next_row(png::uint_32 pos); * void reset(size_t pass); * \endcode * @@ -138,8 +138,7 @@ namespace png #ifdef PNG_WRITE_SWAP_SUPPORTED wr.set_swap(); #else - throw error("Cannot write 16-bit image:" - " recompile with PNG_WRITE_SWAP_SUPPORTED."); + throw error("Cannot write 16-bit image: recompile with PNG_WRITE_SWAP_SUPPORTED."); #endif } #endif @@ -154,12 +153,10 @@ namespace png } else { - throw std::logic_error("Cannot write interlaced image:" - " generator does not support it."); + throw std::logic_error("Cannot write interlaced image: generator does not support it."); } #else - throw error("Cannot write interlaced image:" - " interlace handling disabled."); + throw error("Cannot write interlaced image: interlace handling disabled."); #endif } else @@ -171,7 +168,7 @@ namespace png { pixel_gen->reset(pass); - for (size_t pos = 0; pos < this->get_info().get_height(); ++pos) + for (uint_32 pos = 0; pos < this->get_info().get_height(); ++pos) { wr.write_row(pixel_gen->get_next_row(pos)); } diff --git a/_tools/code_generators/libs/png++/gray_pixel.hpp b/_tools/code_generators/libs/png++/gray_pixel.hpp index c1bdb077b40124cb2a93965ef83417972d254c2f..69978b72a09bdec0c441c808abd6e146090bd15b 100644 --- a/_tools/code_generators/libs/png++/gray_pixel.hpp +++ b/_tools/code_generators/libs/png++/gray_pixel.hpp @@ -52,7 +52,7 @@ namespace png * \brief The packed gray pixel class template. The available * specializations are for 1-, 2- and 4-bit pixels. */ - template< size_t bits > + template< int bits > class packed_gray_pixel : public packed_pixel< bits > { @@ -99,7 +99,7 @@ namespace png /** * \brief Pixel traits specialization for packed_gray_pixel. */ - template< size_t bits > + template< int bits > struct pixel_traits< packed_gray_pixel< bits > > : basic_pixel_traits< packed_gray_pixel< bits >, byte, color_type_gray, /* channels = */ 1, bits > diff --git a/_tools/code_generators/libs/png++/image.hpp b/_tools/code_generators/libs/png++/image.hpp index 0cbf8e4e4c3bdd21e1fdfc20f62a03f206b780c8..bca475a3649d20b9690be8f15b2a71126de78150 100644 --- a/_tools/code_generators/libs/png++/image.hpp +++ b/_tools/code_generators/libs/png++/image.hpp @@ -47,8 +47,18 @@ namespace png * %info like interlace type, compression method, palette (for * colormap-based images) etc. Provides methods to read and write * images from/to a generic stream and to manipulate %image pixels. + * + * The default pixel_buffer stores pixels in a vector of vectors, which + * is good for openning, editing or converting an image to any + * pixel type. + * But for simple and fast image unpacking to one memory chunk this approch + * is unacceptable, because it leads to multiple memory allocations, the + * unpacked image is spread across the memory and client code needs to + * gather it manualy. solid_pixel_buffer solves this problem, but with + * restriction: pixels with fractional number of bytes per channel are + * not allowed (see solid_pixel_buffer.hpp for details). */ - template< typename pixel > + template< typename pixel, typename pixel_buffer_type = pixel_buffer< pixel > > class image { public: @@ -60,12 +70,14 @@ namespace png /** * \brief The pixel buffer type for \c pixel. */ - typedef pixel_buffer< pixel > pixbuf; + typedef pixel_buffer_type pixbuf; /** * \brief Represents a row of image pixel data. */ typedef typename pixbuf::row_type row_type; + typedef typename pixbuf::row_access row_access; + typedef typename pixbuf::row_const_access row_const_access; /** * \brief A transformation functor to convert any image to @@ -92,7 +104,7 @@ namespace png /** * \brief Constructs an empty image of specified width and height. */ - image(size_t width, size_t height) + image(uint_32 width, uint_32 height) : m_info(make_image_info< pixel >()) { resize(width, height); @@ -262,14 +274,6 @@ namespace png write_stream(stream); } - /** - * \brief Writes an image to a stream. - */ - void write_stream(std::ostream& stream) - { - write_stream(stream); - } - /** * \brief Writes an image to a stream. */ @@ -306,12 +310,12 @@ namespace png m_pixbuf = buffer; } - size_t get_width() const + uint_32 get_width() const { return m_pixbuf.get_width(); } - size_t get_height() const + uint_32 get_height() const { return m_pixbuf.get_height(); } @@ -319,7 +323,7 @@ namespace png /** * \brief Resizes the image pixel buffer. */ - void resize(size_t width, size_t height) + void resize(uint_32 width, uint_32 height) { m_pixbuf.resize(width, height); m_info.set_width(width); @@ -332,7 +336,7 @@ namespace png * * \see pixel_buffer::get_row() */ - row_type& get_row(size_t index) + row_access get_row(size_t index) { return m_pixbuf.get_row(index); } @@ -343,7 +347,7 @@ namespace png * * \see pixel_buffer::get_row() */ - row_type const& get_row(size_t index) const + row_const_access get_row(size_t index) const { return m_pixbuf.get_row(index); } @@ -351,7 +355,7 @@ namespace png /** * \brief The non-checking version of get_row() method. */ - row_type& operator[](size_t index) + row_access operator[](size_t index) { return m_pixbuf[index]; } @@ -359,7 +363,7 @@ namespace png /** * \brief The non-checking version of get_row() method. */ - row_type const& operator[](size_t index) const + row_const_access operator[](size_t index) const { return m_pixbuf[index]; } @@ -449,6 +453,16 @@ namespace png m_info.set_tRNS(trns); } + double get_gamma() const + { + return m_info.get_gamma(); + } + + void set_gamma(double gamma) + { + m_info.set_gamma(gamma); + } + protected: /** * \brief A common base class template for pixel_consumer and diff --git a/_tools/code_generators/libs/png++/image_info.hpp b/_tools/code_generators/libs/png++/image_info.hpp index 9b1789039cdbe2e65938070ae89ba1fa5f256d5c..8407bc18b89503a03e494ffb70f616753bce0718 100644 --- a/_tools/code_generators/libs/png++/image_info.hpp +++ b/_tools/code_generators/libs/png++/image_info.hpp @@ -59,26 +59,27 @@ namespace png m_color_type(color_type_none), m_interlace_type(interlace_none), m_compression_type(compression_type_default), - m_filter_type(filter_type_default) + m_filter_type(filter_type_default), + m_gamma(0.0) { } - size_t get_width() const + uint_32 get_width() const { return m_width; } - void set_width(size_t width) + void set_width(uint_32 width) { m_width = width; } - size_t get_height() const + uint_32 get_height() const { return m_height; } - void set_height(size_t height) + void set_height(uint_32 height) { m_height = height; } @@ -93,12 +94,12 @@ namespace png m_color_type = color_space; } - size_t get_bit_depth() const + int get_bit_depth() const { return m_bit_depth; } - void set_bit_depth(size_t bit_depth) + void set_bit_depth(int bit_depth) { m_bit_depth = bit_depth; } @@ -171,16 +172,27 @@ namespace png m_tRNS = trns; } + double get_gamma() const + { + return m_gamma; + } + + void set_gamma(double gamma) + { + m_gamma = gamma; + } + protected: uint_32 m_width; uint_32 m_height; - size_t m_bit_depth; + int m_bit_depth; color_type m_color_type; interlace_type m_interlace_type; compression_type m_compression_type; filter_type m_filter_type; palette m_palette; tRNS m_tRNS; + double m_gamma; }; /** diff --git a/_tools/code_generators/libs/png++/index_pixel.hpp b/_tools/code_generators/libs/png++/index_pixel.hpp index a28b8060d21fc7fb29137a8fe92396d5bba62221..204a2f890230e44803901e4b8a28d34e412364e3 100644 --- a/_tools/code_generators/libs/png++/index_pixel.hpp +++ b/_tools/code_generators/libs/png++/index_pixel.hpp @@ -62,7 +62,7 @@ namespace png * \brief The packed indexed pixel class template. The available * specializations are for 1-, 2- and 4-bit pixels. */ - template< size_t bits > + template< int bits > class packed_index_pixel : public packed_pixel< bits > { @@ -100,7 +100,7 @@ namespace png /** * \brief Pixel traits specialization for packed_index_pixel. */ - template< size_t bits > + template< int bits > struct pixel_traits< packed_index_pixel< bits > > : basic_pixel_traits< packed_index_pixel< bits >, byte, color_type_palette, /* channels = */ 1, bits > diff --git a/_tools/code_generators/libs/png++/info.hpp b/_tools/code_generators/libs/png++/info.hpp index a12bf2a84e59b5333b99c8a3223fac6746e821b7..3f3cf09c311dbf084fb6da465c08258835b78e68 100644 --- a/_tools/code_generators/libs/png++/info.hpp +++ b/_tools/code_generators/libs/png++/info.hpp @@ -75,6 +75,7 @@ namespace png png_get_PLTE(m_png, m_info, & colors, & count); m_palette.assign(colors, colors + count); } + #ifdef PNG_tRNS_SUPPORTED if (png_get_valid(m_png, m_info, chunk_tRNS) == chunk_tRNS) { @@ -91,6 +92,25 @@ namespace png } } #endif + +#ifdef PNG_gAMA_SUPPORTED + if (png_get_valid(m_png, m_info, chunk_gAMA) == chunk_gAMA) + { +#ifdef PNG_FLOATING_POINT_SUPPORTED + if (png_get_gAMA(m_png, m_info, &m_gamma) != PNG_INFO_gAMA) + { + throw error("png_get_gAMA() failed"); + } +#else + png_fixed_point gamma = 0; + if (png_get_gAMA_fixed(m_png, m_info, &gamma) != PNG_INFO_gAMA) + { + throw error("png_get_gAMA_fixed() failed"); + } + m_gamma = gamma / 100000.0; +#endif + } +#endif } void write() const @@ -105,7 +125,7 @@ namespace png { png_set_PLTE(m_png, m_info, const_cast< color* >(& m_palette[0]), - m_palette.size()); + (int) m_palette.size()); } if (! m_tRNS.empty()) { @@ -115,11 +135,25 @@ namespace png m_tRNS.size(), NULL); #else - throw error("attempted to write tRNS chunk;" - " recompile with PNG_tRNS_SUPPORTED"); + throw error("attempted to write tRNS chunk; recompile with PNG_tRNS_SUPPORTED"); #endif } } + + if (m_gamma > 0) + { +#ifdef PNG_gAMA_SUPPORTED +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_gAMA(m_png, m_info, m_gamma); +#else + png_set_gAMA_fixed(m_png, m_info, + (png_fixed_point)(m_gamma * 100000)); +#endif +#else + throw error("attempted to write gAMA chunk; recompile with PNG_gAMA_SUPPORTED"); +#endif + } + png_write_info(m_png, m_info); } diff --git a/_tools/code_generators/libs/png++/io_base.hpp b/_tools/code_generators/libs/png++/io_base.hpp index b089fa9b1ad8b8f6565ce6acea44f10897f1eeee..3c2d830435ef7d5989507305c4c83960b2a7acba 100644 --- a/_tools/code_generators/libs/png++/io_base.hpp +++ b/_tools/code_generators/libs/png++/io_base.hpp @@ -33,10 +33,24 @@ #include <cassert> #include <cstdio> +#include <cstdarg> #include "error.hpp" #include "info.hpp" #include "end_info.hpp" +static void +trace_io_transform(char const* fmt, ...) +{ +#ifdef DEBUG_IO_TRANSFORM + va_list va; + va_start(va, fmt); + fprintf(stderr, "TRANSFORM_IO: "); + vfprintf(stderr, fmt, va); + va_end(va); +#endif +} +#define TRACE_IO_TRANSFORM trace_io_transform + namespace png { @@ -103,22 +117,22 @@ namespace png ////////////////////////////////////////////////////////////////////// // info accessors // - size_t get_width() const + uint_32 get_width() const { return m_info.get_width(); } - void set_width(size_t width) + void set_width(uint_32 width) { m_info.set_width(width); } - size_t get_height() const + uint_32 get_height() const { return m_info.get_height(); } - void set_height(size_t height) + void set_height(uint_32 height) { m_info.set_height(height); } @@ -133,12 +147,12 @@ namespace png m_info.set_color_type(color_space); } - size_t get_bit_depth() const + int get_bit_depth() const { return m_info.get_bit_depth(); } - void set_bit_depth(size_t bit_depth) + void set_bit_depth(int bit_depth) { m_info.set_bit_depth(bit_depth); } @@ -185,16 +199,19 @@ namespace png #if defined(PNG_READ_EXPAND_SUPPORTED) void set_gray_1_2_4_to_8() const { - png_set_gray_1_2_4_to_8(m_png); + TRACE_IO_TRANSFORM("png_set_expand_gray_1_2_4_to_8\n"); + png_set_expand_gray_1_2_4_to_8(m_png); } void set_palette_to_rgb() const { + TRACE_IO_TRANSFORM("png_set_palette_to_rgb\n"); png_set_palette_to_rgb(m_png); } void set_tRNS_to_alpha() const { + TRACE_IO_TRANSFORM("png_set_tRNS_to_alpha\n"); png_set_tRNS_to_alpha(m_png); } #endif // defined(PNG_READ_EXPAND_SUPPORTED) @@ -202,6 +219,7 @@ namespace png #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) void set_bgr() const { + TRACE_IO_TRANSFORM("png_set_bgr\n"); png_set_bgr(m_png); } #endif @@ -209,6 +227,7 @@ namespace png #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) void set_gray_to_rgb() const { + TRACE_IO_TRANSFORM("png_set_gray_to_rgb\n"); png_set_gray_to_rgb(m_png); } #endif @@ -219,6 +238,10 @@ namespace png double red_weight = -1.0, double green_weight = -1.0) const { + TRACE_IO_TRANSFORM("png_set_rgb_to_gray: error_action=%d," + " red_weight=%lf, green_weight=%lf\n", + error_action, red_weight, green_weight); + png_set_rgb_to_gray(m_png, error_action, red_weight, green_weight); } #else @@ -227,6 +250,10 @@ namespace png fixed_point red_weight = -1, fixed_point green_weight = -1) const { + TRACE_IO_TRANSFORM("png_set_rgb_to_gray_fixed: error_action=%d," + " red_weight=%d, green_weight=%d\n", + error_action, red_weight, green_weight); + png_set_rgb_to_gray_fixed(m_png, error_action, red_weight, green_weight); } @@ -238,6 +265,7 @@ namespace png #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) void set_strip_alpha() const { + TRACE_IO_TRANSFORM("png_set_strip_alpha\n"); png_set_strip_alpha(m_png); } #endif @@ -246,6 +274,7 @@ namespace png || defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) void set_swap_alpha() const { + TRACE_IO_TRANSFORM("png_set_swap_alpha\n"); png_set_swap_alpha(m_png); } #endif @@ -254,6 +283,7 @@ namespace png || defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) void set_invert_alpha() const { + TRACE_IO_TRANSFORM("png_set_invert_alpha\n"); png_set_invert_alpha(m_png); } #endif @@ -261,12 +291,18 @@ namespace png #if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) void set_filler(uint_32 filler, filler_type type) const { + TRACE_IO_TRANSFORM("png_set_filler: filler=%08x, type=%d\n", + filler, type); + png_set_filler(m_png, filler, type); } #if !defined(PNG_1_0_X) void set_add_alpha(uint_32 filler, filler_type type) const { + TRACE_IO_TRANSFORM("png_set_add_alpha: filler=%08x, type=%d\n", + filler, type); + png_set_add_alpha(m_png, filler, type); } #endif @@ -275,6 +311,7 @@ namespace png #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) void set_swap() const { + TRACE_IO_TRANSFORM("png_set_swap\n"); png_set_swap(m_png); } #endif @@ -282,6 +319,7 @@ namespace png #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) void set_packing() const { + TRACE_IO_TRANSFORM("png_set_packing\n"); png_set_packing(m_png); } #endif @@ -290,6 +328,7 @@ namespace png || defined(PNG_WRITE_PACKSWAP_SUPPORTED) void set_packswap() const { + TRACE_IO_TRANSFORM("png_set_packswap\n"); png_set_packswap(m_png); } #endif @@ -298,6 +337,10 @@ namespace png void set_shift(byte red_bits, byte green_bits, byte blue_bits, byte alpha_bits = 0) const { + TRACE_IO_TRANSFORM("png_set_shift: red_bits=%d, green_bits=%d," + " blue_bits=%d, alpha_bits=%d\n", + red_bits, green_bits, blue_bits, alpha_bits); + if (get_color_type() != color_type_rgb || get_color_type() != color_type_rgb_alpha) { @@ -313,11 +356,13 @@ namespace png void set_shift(byte gray_bits, byte alpha_bits = 0) const { + TRACE_IO_TRANSFORM("png_set_shift: gray_bits=%d, alpha_bits=%d\n", + gray_bits, alpha_bits); + if (get_color_type() != color_type_gray || get_color_type() != color_type_gray_alpha) { - throw error("set_shift: expected Gray or Gray+Alpha" - " color type"); + throw error("set_shift: expected Gray or Gray+Alpha color type"); } color_info bits; bits.gray = gray_bits; @@ -330,6 +375,7 @@ namespace png || defined(PNG_WRITE_INTERLACING_SUPPORTED) int set_interlace_handling() const { + TRACE_IO_TRANSFORM("png_set_interlace_handling\n"); return png_set_interlace_handling(m_png); } #endif @@ -337,6 +383,7 @@ namespace png #if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) void set_invert_mono() const { + TRACE_IO_TRANSFORM("png_set_invert_mono\n"); png_set_invert_mono(m_png); } #endif @@ -344,6 +391,7 @@ namespace png #if defined(PNG_READ_16_TO_8_SUPPORTED) void set_strip_16() const { + TRACE_IO_TRANSFORM("png_set_strip_16\n"); png_set_strip_16(m_png); } #endif @@ -351,6 +399,7 @@ namespace png #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) void set_read_user_transform(png_user_transform_ptr transform_fn) { + TRACE_IO_TRANSFORM("png_set_read_user_transform_fn\n"); png_set_read_user_transform_fn(m_png, transform_fn); } #endif @@ -359,6 +408,9 @@ namespace png || defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) void set_user_transform_info(void* info, int bit_depth, int channels) { + TRACE_IO_TRANSFORM("png_set_user_transform_info: bit_depth=%d," + " channels=%d\n", bit_depth, channels); + png_set_user_transform_info(m_png, info, bit_depth, channels); } #endif @@ -394,7 +446,7 @@ namespace png void raise_error() { - longjmp(m_png->jmpbuf, -1); + longjmp(png_jmpbuf(m_png), -1); } static void raise_error(png_struct* png, char const* message) diff --git a/_tools/code_generators/libs/png++/packed_pixel.hpp b/_tools/code_generators/libs/png++/packed_pixel.hpp index 7202b4f9838af80b1833b71d8510e1598569f5f1..bf05c47d339a48e8f4ba49f9bde238e0cef1f0d9 100644 --- a/_tools/code_generators/libs/png++/packed_pixel.hpp +++ b/_tools/code_generators/libs/png++/packed_pixel.hpp @@ -38,7 +38,7 @@ namespace png namespace detail { - template< size_t bits > class allowed_bit_depth; + template< int bits > class allowed_bit_depth; template<> class allowed_bit_depth< 1 > {}; template<> class allowed_bit_depth< 2 > {}; @@ -50,7 +50,7 @@ namespace png * * \see packed_gray_pixel, packed_index_pixel */ - template< size_t bits > + template< int bits > class packed_pixel : detail::allowed_bit_depth< bits > { @@ -65,12 +65,12 @@ namespace png return m_value; } - static size_t const get_bit_depth() + static int get_bit_depth() { return bits; } - static byte const get_bit_mask() + static byte get_bit_mask() { return (1 << bits) - 1; } diff --git a/_tools/code_generators/libs/png++/pixel_buffer.hpp b/_tools/code_generators/libs/png++/pixel_buffer.hpp index 4aa16e037a98846b207fd1cfc5385f2b3d989840..07009dfa60931c9bfdd2625aba7cbfc1b21b30a7 100644 --- a/_tools/code_generators/libs/png++/pixel_buffer.hpp +++ b/_tools/code_generators/libs/png++/pixel_buffer.hpp @@ -65,6 +65,8 @@ namespace png * \brief A row of pixel data. */ typedef row row_type; + typedef row_type& row_access; + typedef row_type const& row_const_access; typedef traits row_traits; /** @@ -79,22 +81,22 @@ namespace png /** * \brief Constructs an empty pixel buffer object. */ - basic_pixel_buffer(size_t width, size_t height) + basic_pixel_buffer(uint_32 width, uint_32 height) : m_width(0), m_height(0) { resize(width, height); } - size_t get_width() const + uint_32 get_width() const { return m_width; } - size_t get_height() const - { + uint_32 get_height() const + { return m_height; - } + } /** * \brief Resizes the pixel buffer. @@ -102,7 +104,7 @@ namespace png * If new width or height is greater than the original, * expanded pixels are filled with value of \a pixel(). */ - void resize(size_t width, size_t height) + void resize(uint_32 width, uint_32 height) { m_width = width; m_height = height; @@ -123,7 +125,7 @@ namespace png * std::out_of_range is thrown if \c index is greater than \c * height. */ - row_type& get_row(size_t index) + row_access get_row(size_t index) { return m_rows.at(index); } @@ -134,7 +136,7 @@ namespace png * * The checking version. */ - row_type const& get_row(size_t index) const + row_const_access get_row(size_t index) const { return m_rows.at(index); } @@ -142,7 +144,7 @@ namespace png /** * \brief The non-checking version of get_row() method. */ - row_type& operator[](size_t index) + row_access operator[](size_t index) { return m_rows[index]; } @@ -150,7 +152,7 @@ namespace png /** * \brief The non-checking version of get_row() method. */ - row_type const& operator[](size_t index) const + row_const_access operator[](size_t index) const { return m_rows[index]; } @@ -181,8 +183,8 @@ namespace png } protected: - size_t m_width; - size_t m_height; + uint_32 m_width; + uint_32 m_height; typedef std::vector< row_type > row_vec; row_vec m_rows; }; @@ -216,7 +218,7 @@ namespace png { } - pixel_buffer(size_t width, size_t height) + pixel_buffer(uint_32 width, uint_32 height) : basic_pixel_buffer< pixel, std::vector< pixel > >(width, height) { } @@ -255,7 +257,7 @@ namespace png */ static size_t get_shift(size_t index) { - size_t const bits = pixel::get_bit_depth(); + int const bits = pixel::get_bit_depth(); return (8 - bits) - (index % get_pixels_per_byte()) * bits; } @@ -444,7 +446,7 @@ namespace png * \brief The pixel buffer class template specialization for the * packed_gray_pixel type. */ - template< size_t bits > + template< int bits > class pixel_buffer< packed_gray_pixel< bits > > : public basic_pixel_buffer< packed_gray_pixel< bits >, packed_pixel_row< packed_gray_pixel @@ -458,7 +460,7 @@ namespace png { } - pixel_buffer(size_t width, size_t height) + pixel_buffer(uint_32 width, uint_32 height) : basic_pixel_buffer< pixel_type, pixel_row_type >(width, height) { @@ -469,7 +471,7 @@ namespace png * \brief The pixel buffer class template specialization for the * packed_index_pixel type. */ - template< size_t bits > + template< int bits > class pixel_buffer< packed_index_pixel< bits > > : public basic_pixel_buffer< packed_index_pixel< bits >, packed_pixel_row< packed_index_pixel @@ -483,7 +485,7 @@ namespace png { } - pixel_buffer(size_t width, size_t height) + pixel_buffer(uint_32 width, uint_32 height) : basic_pixel_buffer< pixel_type, pixel_row_type >(width, height) { diff --git a/_tools/code_generators/libs/png++/pixel_traits.hpp b/_tools/code_generators/libs/png++/pixel_traits.hpp index 6500691f1d0f092bcf26b891b40d577d0151129e..8ffdfeedb45609fa9de8a6e17a84bedd672572a5 100644 --- a/_tools/code_generators/libs/png++/pixel_traits.hpp +++ b/_tools/code_generators/libs/png++/pixel_traits.hpp @@ -56,8 +56,8 @@ namespace png template< typename pixel, typename component, color_type pixel_color_type, - size_t channels = sizeof(pixel) / sizeof(component), - size_t bit_depth = std::numeric_limits< component >::digits > + int channels_value = sizeof(pixel) / sizeof(component), + int bit_depth_value = std::numeric_limits< component >::digits > struct basic_pixel_traits { typedef pixel pixel_type; @@ -67,11 +67,15 @@ namespace png { return pixel_color_type; } - static size_t get_channels() + + static const int channels = channels_value; + static int get_channels() { return channels; } - static size_t get_bit_depth() + + static const int bit_depth = bit_depth_value; + static int get_bit_depth() { return bit_depth; } diff --git a/_tools/code_generators/libs/png++/png.hpp b/_tools/code_generators/libs/png++/png.hpp index 1e82c045215857a9ed3fff3a5ceba0db0778d871..e4f45200510331fccdecd29d1b0d0a323233e179 100644 --- a/_tools/code_generators/libs/png++/png.hpp +++ b/_tools/code_generators/libs/png++/png.hpp @@ -54,6 +54,7 @@ #include "generator.hpp" #include "consumer.hpp" #include "pixel_buffer.hpp" +#include "solid_pixel_buffer.hpp" #include "require_color_space.hpp" #include "convert_color_space.hpp" #include "image.hpp" @@ -158,9 +159,9 @@ * #include <png++/png.hpp> * //... * png::image< png::rgb_pixel > image(128, 128); - * for (size_t y = 0; y < image.get_height(); ++y) + * for (png::uint_32 y = 0; y < image.get_height(); ++y) * { - * for (size_t x = 0; x < image.get_width(); ++x) + * for (png::uint_32 x = 0; x < image.get_width(); ++x) * { * image[y][x] = png::rgb_pixel(x, y, x + y); * // non-checking equivalent of image.set_pixel(x, y, ...); @@ -262,10 +263,10 @@ * * Also, you can check out sources directly from SVN repository: * svn://svn.sv.nongnu.org/pngpp/trunk/ or - * http://svn.sv.nongnu.org/pngpp/trunk/ (for people w/o outgoing svn). + * http://svn.sv.nongnu.org/svn/pngpp/trunk/ (for people w/o outgoing svn). * * Online version of this documentation can be found here: - * http://www.nongnu.org/pngpp/doc/0.2.3/index.html + * http://www.nongnu.org/pngpp/doc/ * * \section sec_bugs Bugs * diff --git a/_tools/code_generators/libs/png++/reader.hpp b/_tools/code_generators/libs/png++/reader.hpp index 61dd90cac3335994b8eb0f0a0e34e8aaf8512064..74e2ac17571a2da1d158ab3520b5cdfae75102ff 100644 --- a/_tools/code_generators/libs/png++/reader.hpp +++ b/_tools/code_generators/libs/png++/reader.hpp @@ -92,7 +92,7 @@ namespace png */ void read_png() { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -107,7 +107,7 @@ namespace png */ void read_info() { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -119,7 +119,7 @@ namespace png */ void read_row(byte* bytes) { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -131,7 +131,7 @@ namespace png */ void read_end_info() { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -144,7 +144,7 @@ namespace png } private: - static void read_data(png_struct* png, byte* data, size_t length) + static void read_data(png_struct* png, byte* data, png_size_t length) { io_base* io = static_cast< io_base* >(png_get_error_ptr(png)); reader* rd = static_cast< reader* >(io); diff --git a/_tools/code_generators/libs/png++/solid_pixel_buffer.hpp b/_tools/code_generators/libs/png++/solid_pixel_buffer.hpp new file mode 100644 index 0000000000000000000000000000000000000000..9f84245fd2e25f2cb4d4a044a12b03a341f59950 --- /dev/null +++ b/_tools/code_generators/libs/png++/solid_pixel_buffer.hpp @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2007,2008 Alex Shulgin + * + * This file is part of png++ the C++ wrapper for libpng. PNG++ is free + * software; the exact copying conditions are as follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN + * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef PNGPP_SOLID_PIXEL_BUFFER_HPP_INCLUDED +#define PNGPP_SOLID_PIXEL_BUFFER_HPP_INCLUDED + +#include <cassert> +#include <cstddef> +#include <climits> +#include <stdexcept> +#include <vector> + +#include "config.hpp" +#include "packed_pixel.hpp" +#include "gray_pixel.hpp" +#include "index_pixel.hpp" + +namespace png +{ + + /** + * \brief Pixel buffer, that stores pixels as continuous memory chunk. + * solid_pixel_buffer is useful when user whats to open png, do some + * changes and fetch to buffer to draw (as texture for example). + */ + template< typename pixel > + class solid_pixel_buffer + { + public: + typedef pixel_traits< pixel > pixel_traits_t; + struct row_traits + { + typedef pixel* row_access; + typedef const pixel* row_const_access; + + static byte* get_data(row_access row) + { + return reinterpret_cast<byte*>(row); + } + }; + + + /** + * \brief A row of pixel data. + */ + typedef typename row_traits::row_access row_access; + typedef typename row_traits::row_const_access row_const_access; + typedef row_access row_type; + + /** + * \brief Constructs an empty 0x0 pixel buffer object. + */ + solid_pixel_buffer() + : m_width(0), + m_height(0), + m_stride(0) + { + } + + /** + * \brief Constructs an empty pixel buffer object. + */ + solid_pixel_buffer(uint_32 width, uint_32 height) + : m_width(0), + m_height(0), + m_stride(0) + { + resize(width, height); + } + + uint_32 get_width() const + { + return m_width; + } + + uint_32 get_height() const + { + return m_height; + } + + /** + * \brief Resizes the pixel buffer. + * + * If new width or height is greater than the original, + * expanded pixels are filled with value of \a pixel(). + */ + void resize(uint_32 width, uint_32 height) + { + m_width = width; + m_height = height; + m_stride = m_width * bytes_per_pixel; + m_bytes.resize(height * m_stride); + } + + /** + * \brief Returns a reference to the row of image data at + * specified index. + * + * Checks the index before returning a row: an instance of + * std::out_of_range is thrown if \c index is greater than \c + * height. + */ + row_access get_row(size_t index) + { + return reinterpret_cast<row_access>(&m_bytes.at(index * m_stride)); + } + + /** + * \brief Returns a const reference to the row of image data at + * specified index. + * + * The checking version. + */ + row_const_access get_row(size_t index) const + { + return (row_const_access)(&m_bytes.at(index * m_stride)); + } + + /** + * \brief The non-checking version of get_row() method. + */ + row_access operator[](size_t index) + { + return (row_access)(&m_bytes[index * m_stride]); + } + + /** + * \brief The non-checking version of get_row() method. + */ + row_const_access operator[](size_t index) const + { + return (row_const_access)(&m_bytes[index * m_stride]); + } + + /** + * \brief Replaces the row at specified index. + */ + void put_row(size_t index, row_const_access r) + { + row_access row = get_row(); + for (uint_32 i = 0; i < m_width; ++i) + *row++ = *r++; + } + + /** + * \brief Returns a pixel at (x,y) position. + */ + pixel get_pixel(size_t x, size_t y) const + { + size_t index = (y * m_width + x) * bytes_per_pixel; + return *reinterpret_cast< const pixel* >(&m_bytes.at(index)); + } + + /** + * \brief Replaces a pixel at (x,y) position. + */ + void set_pixel(size_t x, size_t y, pixel p) + { + size_t index = (y * m_width + x) * bytes_per_pixel; + *reinterpret_cast< pixel* >(&m_bytes.at(index)) = p; + } + + /** + * \brief Provides easy constant read access to underlying byte-buffer. + */ + const std::vector< byte >& get_bytes() const + { + return m_bytes; + } + +#ifdef PNGPP_HAS_STD_MOVE + /** + * \brief Moves the buffer to client code (c++11 only) . + */ + std::vector< byte > fetch_bytes() + { + m_width = 0; + m_height = 0; + m_stride = 0; + + // the buffer is moved outside without copying and leave m_bytes empty. + return std::move(m_bytes); + } +#endif + + protected: + static const size_t bytes_per_pixel = pixel_traits_t::channels * + pixel_traits_t::bit_depth / CHAR_BIT; + + protected: + uint_32 m_width; + uint_32 m_height; + size_t m_stride; + std::vector< byte > m_bytes; + +#ifdef PNGPP_HAS_STATIC_ASSERT + static_assert(pixel_traits_t::bit_depth % CHAR_BIT == 0, + "Bit_depth should consist of integer number of bytes"); + + static_assert(sizeof(pixel) * CHAR_BIT == + pixel_traits_t::channels * pixel_traits_t::bit_depth, + "pixel type should contain channels data only"); +#endif + }; + + /** + * \brief solid_pixel_buffer for packed_pixel is not implemented now. + * Should there be a gap between rows? How to deal with last + * useless bits in last byte in buffer? + */ + template< int bits > + class solid_pixel_buffer< packed_pixel< bits > >; + +} // namespace png + +#endif // PNGPP_solid_pixel_buffer_HPP_INCLUDED diff --git a/_tools/code_generators/libs/png++/streaming_base.hpp b/_tools/code_generators/libs/png++/streaming_base.hpp index 68a23dd6a967d34134fecc8828c4b5626efa1331..b63a7934dd81d85a734bf9276a32fb8b3c827acd 100644 --- a/_tools/code_generators/libs/png++/streaming_base.hpp +++ b/_tools/code_generators/libs/png++/streaming_base.hpp @@ -97,7 +97,7 @@ namespace png { } - streaming_base(size_t width, size_t height) + streaming_base(uint_32 width, uint_32 height) : m_info_holder(make_image_info< pixel >()) { get_info().set_width(width); diff --git a/_tools/code_generators/libs/png++/test/Makefile b/_tools/code_generators/libs/png++/test/Makefile deleted file mode 100644 index 5f9f159d43f8b697de654489d1ad85dde1531088..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/Makefile +++ /dev/null @@ -1,101 +0,0 @@ -# -# Copyright (C) 2007,2008 Alex Shulgin -# -# This file is part of png++ the C++ wrapper for libpng. PNG++ is free -# software; the exact copying conditions are as follows: -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# 3. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN -# NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# -ifndef PREFIX -PREFIX := /usr/local -endif - -ifndef PNGPP -PNGPP := .. -endif - -make_cflags := -Wall $(CFLAGS) -I$(PREFIX)/include -I$(PNGPP) -make_ldflags := $(LDFLAGS) -L$(PREFIX)/lib - -ifndef NDEBUG -make_cflags := $(make_cflags) -g -make_ldflags := $(make_ldflags) -g -endif - -ifndef LIBPNG_CONFIG -LIBPNG_CONFIG := libpng-config -endif - -sources := convert_color_space.cpp \ - generate_gray_packed.cpp \ - read_write_gray_packed.cpp \ - generate_palette.cpp \ - write_gray_16.cpp \ - read_write_param.cpp \ - dump.cpp - -deps := $(sources:.cpp=.dep) -objects := $(sources:.cpp=.o) -targets := $(sources:.cpp=$(bin_suffix)) - -all: $(deps) $(targets) - -dist-copy-files: - mkdir $(dist_dir)/test - cp $(sources) Makefile test.sh README *.png $(dist_dir)/test - mkdir $(dist_dir)/test/cmp - cp cmp/*.out $(dist_dir)/test/cmp - -clean: clean-targets clean-tests-output clean-deps - -clean-targets: - rm -f $(targets) $(objects) - -test: all - ./test.sh - -clean-tests-output: - rm -f *.out - -.PHONY: all dist-copy-files \ - clean clean-targets \ - test test-convert_color_space \ - clean-tests-output \ - clean-deps - -%$(bin_suffix): %.o - g++ -o $@ $< $(make_ldflags) `$(LIBPNG_CONFIG) --ldflags` - -%.o: %.cpp - g++ -c -o $@ $< $(make_cflags) `$(LIBPNG_CONFIG) --cflags` - -%.dep: %.cpp - g++ -M $(CPPFLAGS) $(make_cflags) $< -o- | \ - sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@ - -clean-deps: - rm -f $(deps) - -include $(deps) diff --git a/_tools/code_generators/libs/png++/test/README b/_tools/code_generators/libs/png++/test/README deleted file mode 100644 index 714d12c6449e241e5966fdd3d78dea0f2e14cf49..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/README +++ /dev/null @@ -1,85 +0,0 @@ - -pngsuite --------- -(c) Willem van Schaik, 1999 - -Permission to use, copy, and distribute these images for any purpose and -without fee is hereby granted. - -These 15 images are part of the much larger PngSuite test-set of -images, available for developers of PNG supporting software. The -complete set, available at http:/www.schaik.com/pngsuite/, contains -a variety of images to test interlacing, gamma settings, ancillary -chunks, etc. - -The images in this directory represent the basic PNG color-types: -grayscale (1-16 bit deep), full color (8 or 16 bit), paletted -(1-8 bit) and grayscale or color images with alpha channel. You -can use them to test the proper functioning of PNG software. - - filename depth type - ------------ ------ -------------- - basn0g01.png 1-bit grayscale - basn0g02.png 2-bit grayscale - basn0g04.png 4-bit grayscale - basn0g08.png 8-bit grayscale - basn0g16.png 16-bit grayscale - basn2c08.png 8-bit truecolor - basn2c16.png 16-bit truecolor - basn3p01.png 1-bit paletted - basn3p02.png 2-bit paletted - basn3p04.png 4-bit paletted - basn3p08.png 8-bit paletted - basn4a08.png 8-bit gray with alpha - basn4a16.png 16-bit gray with alpha - basn6a08.png 8-bit RGBA - basn6a16.png 16-bit RGBA - -Here is the correct result of typing "pngtest -m *.png" in -this directory: - -Testing basn0g01.png: PASS (524 zero samples) - Filter 0 was used 32 times -Testing basn0g02.png: PASS (448 zero samples) - Filter 0 was used 32 times -Testing basn0g04.png: PASS (520 zero samples) - Filter 0 was used 32 times -Testing basn0g08.png: PASS (3 zero samples) - Filter 1 was used 9 times - Filter 4 was used 23 times -Testing basn0g16.png: PASS (1 zero samples) - Filter 1 was used 1 times - Filter 2 was used 31 times -Testing basn2c08.png: PASS (6 zero samples) - Filter 1 was used 5 times - Filter 4 was used 27 times -Testing basn2c16.png: PASS (592 zero samples) - Filter 1 was used 1 times - Filter 4 was used 31 times -Testing basn3p01.png: PASS (512 zero samples) - Filter 0 was used 32 times -Testing basn3p02.png: PASS (448 zero samples) - Filter 0 was used 32 times -Testing basn3p04.png: PASS (544 zero samples) - Filter 0 was used 32 times -Testing basn3p08.png: PASS (4 zero samples) - Filter 0 was used 32 times -Testing basn4a08.png: PASS (32 zero samples) - Filter 1 was used 1 times - Filter 4 was used 31 times -Testing basn4a16.png: PASS (64 zero samples) - Filter 0 was used 1 times - Filter 1 was used 2 times - Filter 2 was used 1 times - Filter 4 was used 28 times -Testing basn6a08.png: PASS (160 zero samples) - Filter 1 was used 1 times - Filter 4 was used 31 times -Testing basn6a16.png: PASS (1072 zero samples) - Filter 1 was used 4 times - Filter 4 was used 28 times -libpng passes test - -Willem van Schaik -<willem@schaik.com> -October 1999 diff --git a/_tools/code_generators/libs/png++/test/basn0g01.png b/_tools/code_generators/libs/png++/test/basn0g01.png deleted file mode 100644 index e31e1c7a635b50e22b6d02ab8ba21f8099b39faa..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn0g01.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn0g02.png b/_tools/code_generators/libs/png++/test/basn0g02.png deleted file mode 100644 index 68809dd8fc0993ddebce8aa9c7bf9bbecbd36cfc..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn0g02.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn0g04.png b/_tools/code_generators/libs/png++/test/basn0g04.png deleted file mode 100644 index 6fa089cb8a4ba0e8421ea05d33676856f0cac93c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn0g04.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn0g08.png b/_tools/code_generators/libs/png++/test/basn0g08.png deleted file mode 100644 index bf522eef0018ae60539ee1b50e98d97906101f2a..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn0g08.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn0g16.png b/_tools/code_generators/libs/png++/test/basn0g16.png deleted file mode 100644 index 318ebcadf4fd0b64fb9b824e81c0cc8e3dfd2d82..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn0g16.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn2c08.png b/_tools/code_generators/libs/png++/test/basn2c08.png deleted file mode 100644 index 21d2f91a868fc637fdae4fba6c87bfd09b158815..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn2c08.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn2c16.png b/_tools/code_generators/libs/png++/test/basn2c16.png deleted file mode 100644 index 1bd4a4d0e2c2c6dd8a2e63a63b26f166b8ef5353..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn2c16.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn3p01.png b/_tools/code_generators/libs/png++/test/basn3p01.png deleted file mode 100644 index a21db5977462c4c0985a0ca1ac2d67ec572d3d17..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn3p01.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn3p02.png b/_tools/code_generators/libs/png++/test/basn3p02.png deleted file mode 100644 index 1d0ab6197cc8c4dd61e4440cbe98b2149eeafafb..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn3p02.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn3p04.png b/_tools/code_generators/libs/png++/test/basn3p04.png deleted file mode 100644 index 6dc6eac83f3cf984a4d121e27a8e60454117e12c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn3p04.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn3p08.png b/_tools/code_generators/libs/png++/test/basn3p08.png deleted file mode 100644 index 0e07f483c0edad13e60e0d475c33a7ca5b8919ba..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn3p08.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn4a08.png b/_tools/code_generators/libs/png++/test/basn4a08.png deleted file mode 100644 index 3bb0dd06b510cb42855ce91f1600540f4503ea34..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn4a08.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn4a16.png b/_tools/code_generators/libs/png++/test/basn4a16.png deleted file mode 100644 index 6dbee9fbdb93f3535be23326a52fb4d3ac60711e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn4a16.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn6a08.png b/_tools/code_generators/libs/png++/test/basn6a08.png deleted file mode 100644 index 61062308548bc3a5255e3e8dbb7f97932f00eb1c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn6a08.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/basn6a16.png b/_tools/code_generators/libs/png++/test/basn6a16.png deleted file mode 100644 index a9bf3cb461231de29905eaa02f3a8a66f9fc5477..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/basn6a16.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.16.out deleted file mode 100644 index 87745834c5d94a6321adb31ab21ce7f8fb23abff..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.8.out deleted file mode 100644 index aa0dceeff7648fd389c85db957dbe1fdb1b0ae63..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.16.out deleted file mode 100644 index b8cfb9ce3d90eb72ebb6360a5d59ee02be09c550..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.8.out deleted file mode 100644 index ce17a58e6d344ce19a24297e1fcd7461e643b788..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.16.out deleted file mode 100644 index fe8ad377de9459fb9c03ae9f17b7eb3687798b2c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.8.out deleted file mode 100644 index 7ed6eb8d806c6708b9c7ea2c1ba094a57d5ea125..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.16.out deleted file mode 100644 index b6e63e5e9a0974946a9fd443673066c7d7700959..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.8.out deleted file mode 100644 index 1d4b5dd0c4353a715a5e419fff6be9385c079504..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.out b/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.out deleted file mode 100644 index 2ff2c105f2d6c9217cdbe7034d92ab929f52f622..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g01.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.16.out deleted file mode 100644 index 0bf7b82c894a41dd7c6bbe00e913a018fad1e8aa..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.8.out deleted file mode 100644 index 791b9cd12f2dd2eaa82b6a0405318bae2002d51b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.16.out deleted file mode 100644 index 7685bbb4aafb870e90a07a916d5b0ade99cf437b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.8.out deleted file mode 100644 index 94eede03fb47cb9b424e32d0934a733cc2610953..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.16.out deleted file mode 100644 index 1a545ad2e7ed6b7f895f910f41e43c782985e9f6..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.8.out deleted file mode 100644 index 6f939ed37ac8dd615a83a338664da2e9c2b222b0..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.16.out deleted file mode 100644 index 9f2cb535f0e5c33c94ac11b7cce0e8f9cc967527..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.8.out deleted file mode 100644 index 322ba3d6578293770779b1e220f61a16eb041793..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.out b/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.out deleted file mode 100644 index 14edf7741f3099255ea1adc5f474ced1ef7b6962..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g02.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.16.out deleted file mode 100644 index cb21875b6b1ab47dae4230bbbbc535b65f48341e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.8.out deleted file mode 100644 index 5bbae0ed66e7581019aefcfd16c3929678914181..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.16.out deleted file mode 100644 index a7fe5778260b1d33c210f928c4afd26355bd1a45..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.8.out deleted file mode 100644 index 4a0fc341693f5c2d89f2aefb71e6a94bad082111..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.16.out deleted file mode 100644 index 44fb62c149ca80473b0f5c490be05d4edd870e15..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.8.out deleted file mode 100644 index 09fd1e157884d6e999307f1a9f148e2996fc000c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.16.out deleted file mode 100644 index 62beb7950f1993612e6f1161fb577ab6b2749ec4..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.8.out deleted file mode 100644 index 7d4a5306175c5745ab0fc28c458fc28854245e75..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.out b/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.out deleted file mode 100644 index 286cee0178fb2f0cb56f0c149739180a504db93b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g04.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.16.out deleted file mode 100644 index 7794d585b53528c767c454c113bd4db0be633cea..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.8.out deleted file mode 100644 index f8ed14d936402f0aa8cb09a9b933cd505ee60ce2..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.16.out deleted file mode 100644 index 775bee7f4845d3ca4171bed0277381058e8e4070..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.8.out deleted file mode 100644 index dc9dfd76049779727342ed6a2869a67029a42c35..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.16.out deleted file mode 100644 index 460d9e7a97ed27b7c4fa078e61b7e2f05eda0f46..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.8.out deleted file mode 100644 index 9efa9c2ff2940756ec0573c8d0679fb4f7da1998..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.16.out deleted file mode 100644 index 1e46f172793d5c815db9b1c51a36428439ed8236..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.8.out deleted file mode 100644 index 5ae1c710852efcac319a4dda96cca960c6ac1805..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g08.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.16.out deleted file mode 100644 index 1abcb325a9ffa48a7e69564e8ee2adf839974f57..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.8.out deleted file mode 100644 index bed384dc1c76fa1ae8f9b0eaddbdde0f7d165054..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.16.out deleted file mode 100644 index 991c6e8f09d40a5a69d429f0d529fa8512e68045..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.8.out deleted file mode 100644 index d10ee386f92634f49157090c888ae2661a0e905b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.16.out deleted file mode 100644 index a9340b1105a9b034cf3e339c7b54e7d60ae33148..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.8.out deleted file mode 100644 index eae1e7b597c36fa501b8ef888e499fbc4abac46d..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.16.out deleted file mode 100644 index 99f20554e22a058e979a4f4ad59451d1e45735a3..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.8.out deleted file mode 100644 index d95f5210962092daacdc68873b50a3e9d6e1f733..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn0g16.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.16.out deleted file mode 100644 index 27ae8dff48c71cf5ae3dcc09c3a9d652de637641..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.8.out deleted file mode 100644 index 624bf3a7d824bd47e5bf6a327f2ba6fc6f81e7cf..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.16.out deleted file mode 100644 index ba23dfe07dc9d521cd63c352eb8e1cef5c406ccf..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.8.out deleted file mode 100644 index d678379313a7d1e34b1510a12d2e9ac5cbc1f331..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.16.out deleted file mode 100644 index d309464adc1b91382749f0b85ba49ed8b04c975b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.8.out deleted file mode 100644 index 77caf74462f946aad448d9d308d930f0d1080707..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.16.out deleted file mode 100644 index baf0adbbcb1748454e7660744d4c227bfc90d476..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.8.out deleted file mode 100644 index 6a1dbe396145c7341e1d934c38f1e3908ea807a9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c08.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.16.out deleted file mode 100644 index bb4b0750bb7e07f71d08d25f5e135fae92dfc3c7..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.8.out deleted file mode 100644 index a151e85b970cecfba8acd22b15c5ff96f1259ebc..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.16.out deleted file mode 100644 index 980c57dbc48a01801069277779a5239fd9415487..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.8.out deleted file mode 100644 index 8d62e832e500a1ca04395c682e66fd4c2039fe43..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.16.out deleted file mode 100644 index 5df647ad3b4a7ef78b8fe7da00e5272979006381..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.8.out deleted file mode 100644 index b097f70d4b24b38cdaf3842bd837407a28e2cf6a..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.16.out deleted file mode 100644 index c4445dcd2cde938c82a7b6d84c25d284d04badd6..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.8.out deleted file mode 100644 index 80a60428ea1a4f989a15f89e458bff304b4023c6..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn2c16.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.16.out deleted file mode 100644 index 3eb65611887a0c5cf3de925153abaa79fff8ab63..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.8.out deleted file mode 100644 index 0c97e0155b6cce97ee6f4f92c04db1ba20cac26b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.16.out deleted file mode 100644 index 21100ff612c44d9391f362a7a570af5fabe2ad5e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.8.out deleted file mode 100644 index c5c08cb8491ef6e468f47fb2efb83826670b1182..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.16.out deleted file mode 100644 index 6c65197cb79205be6e62512abaf3271c80710f6e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.8.out deleted file mode 100644 index e834bc528ed144668fbd6bf8b1ab6126a78a653d..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.16.out deleted file mode 100644 index bc2028359b9ddb12c1b66768d49c622ce0b19d7a..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.8.out deleted file mode 100644 index 354293b02954922794fc1c28398ab9a6e3d02fdb..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p01.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.16.out deleted file mode 100644 index d3524e2b4dcac872856cf7808a24403c3c608070..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.8.out deleted file mode 100644 index 73155c403d755cc814d48937bfbab739f2b43292..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.16.out deleted file mode 100644 index 4318e36d07d3eb46bca18ebb04ea49a40efa8fb6..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.8.out deleted file mode 100644 index 4c4de6132b3894235fd23e3efcb234a22005df32..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.16.out deleted file mode 100644 index 771d34f87cad1e3b123c88ae819be14bff307faf..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.8.out deleted file mode 100644 index 38f0df85689dbb049dc5aa95e51f29ba03ad63c2..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.16.out deleted file mode 100644 index 1e9a2825c624cec89b040866710a336e774e55e1..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.8.out deleted file mode 100644 index 19ea90bd4b27f86dc85914c7f7452edf67d77c2f..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p02.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.16.out deleted file mode 100644 index ab167c90b486e826e7548f8289d31c316a022113..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.8.out deleted file mode 100644 index 82ffc2ae7d62ac1c09f528c77c41d3c091d4840e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.16.out deleted file mode 100644 index c86fb96edd82e749f0dd14d46927a3e0d326d045..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.8.out deleted file mode 100644 index f472ee82940a7ab03b1c81f5cfd9af5727ec4d2b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.16.out deleted file mode 100644 index 585adcca4db7f6a604bc480474942e5a20189b7b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.8.out deleted file mode 100644 index c987d28eaebe89c8722b3ba052a61d7c6a8c29e6..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.16.out deleted file mode 100644 index 45d93893bc8fcf3f963f998bb0ec1610f0ac6e71..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.8.out deleted file mode 100644 index fe9ac5656740ccf33d0f244cdfbab743a83a56ca..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p04.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.16.out deleted file mode 100644 index 0a751b6ee7171bf4ed85d778114b1de2ddd9aaed..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.8.out deleted file mode 100644 index 4dc8f80df0ce44e2ef0cb51caf2d45c88ca44374..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.16.out deleted file mode 100644 index 68de54d0a19aa4836b906a3899e00690354406e9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.8.out deleted file mode 100644 index d1e650e00d01749c4b65c2df2335e1550b5d38f9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.16.out deleted file mode 100644 index 1fd97fa7fc94b6e59e1afd9a8519fafe72411528..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.8.out deleted file mode 100644 index 86011898fc27646a0a92404e60f3c2418508ff3b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.16.out deleted file mode 100644 index fe00181f6dd31cdfc7849655f939b3e3b7afa4e2..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.8.out deleted file mode 100644 index 5cde524cf52d0c0253504be7b0ad64286136560f..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn3p08.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.16.out deleted file mode 100644 index 982a7758ff9282e4357682b27db5081734357013..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.8.out deleted file mode 100644 index b8ef393743d3a9ca47fde6f5c30c67e90d0a8ad5..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.16.out deleted file mode 100644 index 5a693596ffaba5d59e2f4add03afabb751ba96ab..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.8.out deleted file mode 100644 index 89b58c02f409b3e7518eea4aa57c77de35edcb71..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.16.out deleted file mode 100644 index 36ef6d2c325a9b8e9b2691072092fe2cf74270d7..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.8.out deleted file mode 100644 index 32dec3a4df27e127d58ef95dce4be13820d4ab43..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.16.out deleted file mode 100644 index e65898c2d0772891c83d7a79968e9d587bc23e34..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.8.out deleted file mode 100644 index 8a903f6316ae1cb3b1e81d738223033d01c427b1..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a08.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.16.out deleted file mode 100644 index 978a585d950eb8a278ce21913aa30bc07cdb61c1..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.8.out deleted file mode 100644 index 34c98079618c714c46ee1d48a9c815fbbff4951b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.16.out deleted file mode 100644 index a78fb79903c56e5634cde5c3e197d31582513b28..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.8.out deleted file mode 100644 index 36f86cfe50f0d43f8f5c68f21dd7bbd716466fe9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.16.out deleted file mode 100644 index 2a537f0b23ca95c8e80ccad371cce0d6bdea07a5..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.8.out deleted file mode 100644 index a239300b79763d97817c858de784bc544761313f..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.16.out deleted file mode 100644 index e83bfd45b19bbde661dce94ecdce1b9a850b3ade..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.8.out deleted file mode 100644 index 1481fb0c92eb4dc4ebfb5d22688755ec2daba4d9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn4a16.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.16.out deleted file mode 100644 index 0c13f717f29fe01dddb3f8777beca7463544c53a..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.8.out deleted file mode 100644 index cf54821fadf8c6ba0342844b86d7fd1e5bbd0e86..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.16.out deleted file mode 100644 index c846ca3e2de24cd86aad7ff2be20142afd35c546..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.8.out deleted file mode 100644 index 3e7a231593aac14acd5c14efeedb460ad9444c3e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.16.out deleted file mode 100644 index 9c12d3a6cb7e10d647e20671b695d80108701cc5..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.8.out deleted file mode 100644 index 31978afa8a91334521215178599f61142bdc4390..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.16.out deleted file mode 100644 index 1f354e39b3f0356603216a6cebcb89a2ef0ca11c..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.8.out deleted file mode 100644 index ef0ebe4e27ef70bb1745b0e11feaabc66b8da75e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a08.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.16.out deleted file mode 100644 index 5f9c114f3f741233c882ab9069a7dd6c0f1bd38e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.8.out deleted file mode 100644 index 058d111de30d9035fa0a9a40d406ce52a44c7bb3..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.16.out deleted file mode 100644 index b874c94c576756ad3a0fdcd722c54a068e64782b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.8.out deleted file mode 100644 index c3245fb1e5cf2f89c7825916eccc1eea00b6ef1d..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.16.out deleted file mode 100644 index 8c98fc294128e4b0d68cb363f31913e1aa08defd..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.8.out deleted file mode 100644 index 2c36574281524b3c36a737649505b7d46e494b10..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.16.out deleted file mode 100644 index 51ea33fa528d3e15b66720658ca58b32c9ecd8c3..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.8.out deleted file mode 100644 index a78219c29b7368cc6908948fc83104b5ec0b62eb..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/basn6a16.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/gray_16.out b/_tools/code_generators/libs/png++/test/cmp/gray_16.out deleted file mode 100644 index e405f4e1253a266f180645472b751ce0e18a69c8..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/gray_16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/gray_packed_1.png.out b/_tools/code_generators/libs/png++/test/cmp/gray_packed_1.png.out deleted file mode 100644 index 238628050db4b5b95143b97049d1782b39be9cc9..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/gray_packed_1.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/gray_packed_2.png.out b/_tools/code_generators/libs/png++/test/cmp/gray_packed_2.png.out deleted file mode 100644 index fb0e9c7c9bcf4edf0c78d00db465d9abdd3d12d3..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/gray_packed_2.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/gray_packed_4.png.out b/_tools/code_generators/libs/png++/test/cmp/gray_packed_4.png.out deleted file mode 100644 index 5d5563ab28e9e2bef551619226bf1b51186cea84..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/gray_packed_4.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.16.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.16.out deleted file mode 100644 index ca364b29b8a77b77e5c2b922735ab84e4ce878e1..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.8.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.8.out deleted file mode 100644 index 2fb3afaf4051b3dbb820cf2f2275e88390540691..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.16.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.16.out deleted file mode 100644 index 81139f7173154098c701104e297b8be549dd75ce..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.8.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.8.out deleted file mode 100644 index 9dd1ecdd1f282df6d202c52ae2890c8ea1b7b3e8..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.GRAY.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.16.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.16.out deleted file mode 100644 index 9dfaf8d7f7020d9e0fd2d5e2bb12b1aa41512044..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.8.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.8.out deleted file mode 100644 index ac0d03179b22e92fe52521b5967f9ce1f7546790..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGB.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.16.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.16.out deleted file mode 100644 index 47cf3ff50ab01fd8f31d400b6331e3cdb4d8d099..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.16.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.8.out b/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.8.out deleted file mode 100644 index fe428a3b8ddffa69ca35129b82aec0615fd76aed..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/interlace.png.RGBA.8.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/palette1.png.out b/_tools/code_generators/libs/png++/test/cmp/palette1.png.out deleted file mode 100644 index ee4323b2fe29283fed6817592868242f40aec608..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/palette1.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/palette2.png.out b/_tools/code_generators/libs/png++/test/cmp/palette2.png.out deleted file mode 100644 index ba7fad816501e85bd3c5fe116053567aedfac430..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/palette2.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/palette4.png.out b/_tools/code_generators/libs/png++/test/cmp/palette4.png.out deleted file mode 100644 index 1b1132bbe7b67dc1563d0e2d032c496601f7d58e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/palette4.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/palette8.png.out b/_tools/code_generators/libs/png++/test/cmp/palette8.png.out deleted file mode 100644 index 1b5ea446d6037c855034c9cc6b28bfee7e90fe9e..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/palette8.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/cmp/palette8_tRNS.png.out b/_tools/code_generators/libs/png++/test/cmp/palette8_tRNS.png.out deleted file mode 100644 index 0d3da33341fabbf3f16d661c5f6453f1cb4a788b..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/cmp/palette8_tRNS.png.out and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/convert_color_space.cpp b/_tools/code_generators/libs/png++/test/convert_color_space.cpp deleted file mode 100644 index 2f598ded6def4a8e00399fe112e2606fb424bfa1..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/convert_color_space.cpp +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) 2007,2008 Alex Shulgin - * - * This file is part of png++ the C++ wrapper for libpng. PNG++ is free - * software; the exact copying conditions are as follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -void -print_usage() -{ - std::cerr << "usage: convert_color_space RGB|RGBA|GRAY|GA 8|16" - << " INFILE OUTFILE" << std::endl; -} - -int -main(int argc, char* argv[]) -try -{ - if (argc != 5) - { - print_usage(); - return EXIT_FAILURE; - } - char const* space = argv[1]; - int bits = atoi(argv[2]); - char const* infile = argv[3]; - char const* outfile = argv[4]; - - if (bits != 8 && bits != 16) - { - print_usage(); - return EXIT_FAILURE; - } - if (strcmp(space, "RGB") == 0) - { - if (bits == 16) - { - png::image< png::rgb_pixel_16 > image(infile); - image.write(outfile); - } - else - { - png::image< png::rgb_pixel > image(infile); - image.write(outfile); - } - } - else if (strcmp(space, "RGBA") == 0) - { - if (bits == 16) - { - png::image< png::rgba_pixel_16 > image(infile); - image.write(outfile); - } - else - { - png::image< png::rgba_pixel > image(infile); - image.write(outfile); - } - } - else if (strcmp(space, "GRAY") == 0) - { - if (bits == 16) - { - png::image< png::gray_pixel_16 > image(infile); - image.write(outfile); - } - else - { - png::image< png::gray_pixel > image(infile); - image.write(outfile); - } - } - else if (strcmp(space, "GA") == 0) - { - if (bits == 16) - { - png::ga_pixel_16 ga(1); // test alpha_pixel_traits - - png::image< png::ga_pixel_16 > image(infile); - image.write(outfile); - } - else - { - png::ga_pixel ga(1); // test alpha_pixel_traits - - png::image< png::ga_pixel > image(infile); - image.write(outfile); - } - } - else - { - print_usage(); - return EXIT_FAILURE; - } -} -catch (std::exception const& error) -{ - std::cerr << "convert_color_space: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/test/dump.cpp b/_tools/code_generators/libs/png++/test/dump.cpp deleted file mode 100644 index 038ab6d0a4a3fbcf4227c11e5e017b28930ea750..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/dump.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -// inline png::uint_16 -// to_png_order(png::uint_16 x) -// { -// return ((x & 0xff) << 8) | (x >> 8); -// } - -int -main(int argc, char* argv[]) -try -{ - if (argc != 2) - { - throw std::runtime_error("usage: dump PNG"); - } - char const* file = argv[1]; - png::image< png::gray_pixel_16 > image(file); - for (size_t y = 0; y < image.get_height(); ++y) - { - for (size_t x = 0; x < image.get_width(); ++x) - { - if (x) - { - putchar(' '); - } - printf("%04x", image[y][x]); - } - putchar('\n'); - } -} -catch (std::exception const& error) -{ - std::cerr << "dump: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/test/generate_gray_packed.cpp b/_tools/code_generators/libs/png++/test/generate_gray_packed.cpp deleted file mode 100644 index d2106e7c385345d87d703157ca1fe044ac161633..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/generate_gray_packed.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007,2008 Alex Shulgin - * - * This file is part of png++ the C++ wrapper for libpng. PNG++ is free - * software; the exact copying conditions are as follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -template< class pixel > -void -generate_image(png::image< pixel >& image, char const* filename) -{ - for (size_t j = 0; j < image.get_height(); ++j) - { - for (size_t i = 0; i < image.get_width(); ++i) - { - image.set_pixel(i, j, pixel(i + j)); - } - } - image.write(filename); -} - -int -main(int argc, char* argv[]) -try -{ - size_t const width = 32; - size_t const height = 32; - - png::image< png::gray_pixel_1 > image1(width, height); - generate_image(image1, "gray_packed_1.png.out"); - - png::image< png::gray_pixel_2 > image2(width, height); - generate_image(image2, "gray_packed_2.png.out"); - - png::image< png::gray_pixel_4 > image4(width, height); - generate_image(image4, "gray_packed_4.png.out"); -} -catch (std::exception const& error) -{ - std::cerr << "generate_gray_packed: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/test/generate_palette.cpp b/_tools/code_generators/libs/png++/test/generate_palette.cpp deleted file mode 100644 index 4fb9f97365faf2a581cb5ddd3e7d2ab494dfdc3b..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/generate_palette.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (C) 2007,2008 Alex Shulgin - * - * This file is part of png++ the C++ wrapper for libpng. PNG++ is free - * software; the exact copying conditions are as follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -template< typename pixel > -void -generate_image(png::image< pixel >& image) -{ - typedef png::pixel_traits< pixel > traits; - size_t colors = 1 << traits::get_bit_depth(); - size_t size = colors / 2; - image.resize(size, size); - - png::palette palette(colors); - for (size_t c = 0; c < colors; ++c) - { - palette[c] = png::color(c * 255 / colors, - (colors - c - 1) * 255 / colors, - c * 255 / colors); - } - image.set_palette(palette); - for (size_t j = 0; j < image.get_height(); ++j) - { - for (size_t i = 0; i < image.get_width(); ++i) - { - image.set_pixel(i, j, i + j); - } - } -} - -int -main() -try -{ - png::image< png::index_pixel_1 > image1; - generate_image(image1); - image1.write("palette1.png.out"); - - png::image< png::index_pixel_2 > image2; - generate_image(image2); - image2.write("palette2.png.out"); - - png::image< png::index_pixel_4 > image4; - generate_image(image4); - image4.write("palette4.png.out"); - - png::image< png::index_pixel > image8; - generate_image(image8); - image8.write("palette8.png.out"); - - png::image< png::index_pixel > image8_tRNS; - generate_image(image8_tRNS); - png::tRNS trns(256); - for (size_t i = 0; i < trns.size(); ++i) - { - trns[i] = i; - } - image8_tRNS.set_tRNS(trns); - image8_tRNS.write("palette8_tRNS.png.out"); -} -catch (std::exception const& error) -{ - std::cerr << "generate_palette: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/test/interlace.png b/_tools/code_generators/libs/png++/test/interlace.png deleted file mode 100644 index 8a3f4a9d97036598c0a572b59a1128d7ce668b82..0000000000000000000000000000000000000000 Binary files a/_tools/code_generators/libs/png++/test/interlace.png and /dev/null differ diff --git a/_tools/code_generators/libs/png++/test/read_write_gray_packed.cpp b/_tools/code_generators/libs/png++/test/read_write_gray_packed.cpp deleted file mode 100644 index 1f51c54e45ef046d12ea48ba9de3edaf2f8d23e6..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/read_write_gray_packed.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2007,2008 Alex Shulgin - * - * This file is part of png++ the C++ wrapper for libpng. PNG++ is free - * software; the exact copying conditions are as follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -void -print_usage() -{ - std::cerr << "usage: read_write_gray_packed 1|2|4 INFILE OUTFILE" - << std::endl; -} - -template< class pixel > -void -test_image(char const* infile, char const* outfile) -{ - png::image< pixel > image(infile, png::require_color_space< pixel >()); - image.write(outfile); -} - -int -main(int argc, char* argv[]) -try -{ - if (argc != 4) - { - print_usage(); - return EXIT_FAILURE; - } - char const* bits = argv[1]; - char const* infile = argv[2]; - char const* outfile = argv[3]; - - if (strcmp(bits, "1") == 0) - { - test_image< png::gray_pixel_1 >(infile, outfile); - } - else if (strcmp(bits, "2") == 0) - { - test_image< png::gray_pixel_2 >(infile, outfile); - } - else if (strcmp(bits, "4") == 0) - { - test_image< png::gray_pixel_4 >(infile, outfile); - } - else - { - print_usage(); - return EXIT_FAILURE; - } -} -catch (std::exception const& error) -{ - std::cerr << "read_write_gray_packed: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/test/read_write_param.cpp b/_tools/code_generators/libs/png++/test/read_write_param.cpp deleted file mode 100644 index c755f4d87b7ec0e571001dd62f5c87fe374eb04d..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/read_write_param.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -int -main() -{ - std::cerr << "read_write_param: do not run this test--it's compile-only" - << std::endl; - exit(1); - - typedef png::image< png::rgb_pixel > image; - image image1; // default contructor - image image2("test2.png"); // char const* - char test3[] = "test3.png"; // char* - image image3(test3); - image image4(std::string("test4.png")); - - image1.write("test4.png"); // char const* - char test5[] = "test5.png"; - image1.write(test5); // char* - image1.write(std::string("test6.png")); -} diff --git a/_tools/code_generators/libs/png++/test/test.sh b/_tools/code_generators/libs/png++/test/test.sh deleted file mode 100644 index 9329b0ab55d4ea4e604f8782ef4621787f28c8b3..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/test.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh - -status=0 - -for i in *.png; do - for j in RGB RGBA GRAY GA; do - for k in 8 16; do - out=$i.$j.$k.out - echo ./convert_color_space $j $k $i $out - ./convert_color_space $j $k $i $out && cmp $out cmp/$out \ - || status=1 - done; - done; -done - -echo ./generate_gray_packed -./generate_gray_packed || status=1 -for i in 1 2 4; do - out=gray_packed_$i.png.out - cmp $out cmp/$out || status=1 -done - -for i in 1 2 4; do - in=basn0g0$i.png - out=$in.out - echo ./read_write_gray_packed $i $in $out - ./read_write_gray_packed $i $in $out && cmp $out cmp/$out || status=1 -done - -echo ./generate_palette -./generate_palette || status=1 -for i in 1 2 4 8; do - out=palette$i.png.out - cmp $out cmp/$out || status=1 -done -cmp palette8_tRNS.png.out cmp/palette8_tRNS.png.out || status=1 - -echo ./write_gray_16 -./write_gray_16 && cmp gray_16.out cmp/gray_16.out || status=1 - -test $status -eq 0 && echo 'PNG++ PASSES TESTS' || echo 'PNG++ FAILS TESTS' -exit $status diff --git a/_tools/code_generators/libs/png++/test/write_gray_16.cpp b/_tools/code_generators/libs/png++/test/write_gray_16.cpp deleted file mode 100644 index 6c7f922336efbccb22767864836566c781353cd4..0000000000000000000000000000000000000000 --- a/_tools/code_generators/libs/png++/test/write_gray_16.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2007,2008 Alex Shulgin - * - * This file is part of png++ the C++ wrapper for libpng. PNG++ is free - * software; the exact copying conditions are as follows: - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN - * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -#include <iostream> -#include <ostream> - -#include <png.hpp> - -int -main() -try -{ - png::image< png::gray_pixel_16 > image(256, 256); - for (size_t y = 0; y < image.get_height(); ++y) - { - for (size_t x = 0; x < image.get_width(); ++x) - { - png::gray_pixel_16 pix = x*y; - image[y][x] = pix; - } - } - image.write("gray_16.out"); -} -catch (std::exception const& error) -{ - std::cerr << "write_gray_16: " << error.what() << std::endl; - return EXIT_FAILURE; -} diff --git a/_tools/code_generators/libs/png++/writer.hpp b/_tools/code_generators/libs/png++/writer.hpp index 05e28e8f3e1a653688523454ec0a0be80b72d30c..448dfd50b1dc841aa2c8ad61bed78aa023ec7592 100644 --- a/_tools/code_generators/libs/png++/writer.hpp +++ b/_tools/code_generators/libs/png++/writer.hpp @@ -88,7 +88,7 @@ namespace png void write_png() const { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -103,7 +103,7 @@ namespace png */ void write_info() const { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -115,7 +115,7 @@ namespace png */ void write_row(byte* bytes) { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -127,7 +127,7 @@ namespace png */ void write_end_info() const { - if (setjmp(m_png->jmpbuf)) + if (setjmp(png_jmpbuf(m_png))) { throw error(m_error); } @@ -135,7 +135,7 @@ namespace png } private: - static void write_data(png_struct* png, byte* data, size_t length) + static void write_data(png_struct* png, byte* data, png_size_t length) { io_base* io = static_cast< io_base* >(png_get_error_ptr(png)); writer* wr = static_cast< writer* >(io); diff --git a/_tools/code_generators/resourcefs.cpp b/_tools/code_generators/resourcefs.cpp index 7bd4257ce715ef4557cc2a9c67a21990c6788359..7f382b39d6d2cc2207180fd23f51ba5e1cb792df 100644 --- a/_tools/code_generators/resourcefs.cpp +++ b/_tools/code_generators/resourcefs.cpp @@ -37,7 +37,7 @@ using namespace std; using namespace boost::program_options; -using namespace boost::filesystem; +namespace fs = boost::filesystem; /** * \param an unsigned int @@ -83,10 +83,10 @@ int main(int argc, char *argv[]) } //Traverse the input directory storing path of files - path inDir(vm["in"].as<string>()); - directory_iterator end; - vector<path> files; - for(directory_iterator it(inDir);it!=end;++it) + fs::path inDir(vm["in"].as<string>()); + fs::directory_iterator end; + vector<fs::path> files; + for(fs::directory_iterator it(inDir);it!=end;++it) { if(is_directory(it->status())) { diff --git a/drivers/display_st7735.cpp b/drivers/display_st7735.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3b51b9d5b15dc93f518138b121391edbb3541239 --- /dev/null +++ b/drivers/display_st7735.cpp @@ -0,0 +1,348 @@ +/*************************************************************************** + * Copyright (C) 2021 by Salaorni Davide, Velati Matteo * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * As a special exception, if other files instantiate templates or use * + * macros or inline functions from this file, or you compile this file * + * and link it with other works to produce a work based on this file, * + * this file does not by itself cause the resulting work to be covered * + * by the GNU General Public License. However the source code for this * + * file must still be made available in accordance with the GNU General * + * Public License. This exception does not invalidate any other reasons * + * why a work based on this file might be covered by the GNU General * + * Public License. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see <http://www.gnu.org/licenses/> * + ***************************************************************************/ + +#include "display_st7735.h" +#include "font.h" +#include "image.h" +#include "misc_inst.h" +#include "line.h" + +using namespace std; +using namespace miosix; + +namespace mxgui { + +/** + * Init sequence for the correct functioning of the ST7735 display + */ +const unsigned char initST7735b[] = { + 0x3A, 0X01, 0x05, // ST7735_COLMOD, color mode: 16-bit/pixel + 0xB1, 0x03, 0x00, 0x06, 0x03, // ST7735_FRMCTR1, normal mode frame rate + 0xB6, 0x02, 0x15, 0x02, // ST7735_DISSET5, display settings + 0xB4, 0x01, 0x00, // ST7735_INVCTR, line inversion active + 0xC0, 0x02, 0x02, 0x70, // ST7735_PWCTR1, default (4.7V, 1.0 uA) + 0xC1, 0x01, 0x05, // ST7735_PWCTR2, default (VGH=14.7V, VGL=-7.35V) + 0xC3, 0x02, 0x02, 0x07, // ST7735_PWCTR4, bclk/2, opamp current small and medium low + 0xC5, 0x02, 0x3C, 0x38, // ST7735_VMCTR1, VCOMH=4V VCOML=-1.1 + 0xFC, 0x02, 0x11, 0x15, // ST7735_PWCTR6, power control (partial mode+idle) + 0xE0, 0x10, // ST7735_GMCTRP1, Gamma adjustments (pos. polarity) + 0x09, 0x16, 0x09, 0x20, // (Not entirely necessary, but provides + 0x21, 0x1B, 0x13, 0x19, // accurate colors) + 0x17, 0x15, 0x1E, 0x2B, + 0x04, 0x05, 0x02, 0x0E, + 0xE1, 0x10, // ST7735_GMCTRN1, Gamma adjustments (neg. polarity) + 0x0B, 0x14, 0x08, 0x1E, // (Not entirely necessary, but provides + 0x22, 0x1D, 0x18, 0x1E, // accurate colors) + 0x1B, 0x1A, 0x24, 0x2B, + 0x06, 0x06, 0x02, 0x0F, + 0x13, // ST7735_NORON, normal display mode on + 0x00 +}; + +/** + * Class DisplayGenericST7735 + */ +void DisplayGenericST7735::doTurnOn() { + writeReg(0x29); //ST7735_DISPON + delayMs(150); +} + +void DisplayGenericST7735::doTurnOff() { + writeReg(0x28); //ST7735_DISPOFF + delayMs(150); +} + +void DisplayGenericST7735::doSetBrightness(int brt) { + //No function to set brightness for this display +} + +pair<short int, short int> DisplayGenericST7735::doGetSize() const { + return make_pair(height, width); +} + +void DisplayGenericST7735::write(Point p, const char *text) { + font.draw(*this, textColor, p, text); +} + +void DisplayGenericST7735::clippedWrite(Point p, Point a, Point b, const char *text) { + font.clippedDraw(*this, textColor, p, a, b, text); +} + +void DisplayGenericST7735::clear(Color color) { + clear(Point(0,0), Point(width-1, height-1), color); +} + +void DisplayGenericST7735::clear(Point p1, Point p2, Color color) { + unsigned char lsb = color & 0xFF; + unsigned char msb = (color >> 8) & 0xFF; + + imageWindow(p1, p2); + int numPixels = (p2.x() - p1.x() + 1) * (p2.y() - p1.y() + 1); + + Transaction t(csx); + writeRamBegin(); + + //Send data to write on GRAM + for(int i=0; i < numPixels; i++) { + writeRam(msb); + writeRam(lsb); + } +} + +void DisplayGenericST7735::beginPixel() { + imageWindow(Point(0,0), Point(width-1, height-1)); +} + +void DisplayGenericST7735::setPixel(Point p, Color color) { + unsigned char lsb = color & 0xFF; + unsigned char msb = (color >> 8) & 0xFF; + + setCursor(p); + Transaction t(csx); + writeRamBegin(); + writeRam(msb); + writeRam(lsb); +} + +void DisplayGenericST7735::line(Point a, Point b, Color color) { + unsigned char lsb = color & 0xFF; + unsigned char msb = (color >> 8) & 0xFF; + + //Horizontal line speed optimization + if(a.y() == b.y()) + { + imageWindow(Point(min(a.x(), b.x()), a.y()), Point(max(a.x(), b.x()), a.y())); + int numPixels = abs(a.x() - b.x()); + + Transaction t(csx); + writeRamBegin(); + + //Send data to write on GRAM + for(int i=0; i <= numPixels; i++) { + writeRam(msb); + writeRam(lsb); + } + return; + } + //Vertical line speed optimization + if(a.x() == b.x()) + { + textWindow(Point(a.x(), min(a.y(), b.y())), Point(a.x(), max(a.y(), b.y()))); + int numPixels = abs(a.y() - b.y()); + + Transaction t(csx); + writeRamBegin(); + + //Send data to write on GRAM + for(int i=0; i <= numPixels; i++) { + writeRam(msb); + writeRam(lsb); + } + return; + } + //General case, always works but it is much slower due to the display + //not having fast random access to pixels + Line::draw(*this, a, b, color); +} + +void DisplayGenericST7735::scanLine(Point p, const Color *colors, unsigned short length) { + unsigned char lsb = 0x00; + unsigned char msb = 0x00; + + if(p.x() + length > width) { return; } + imageWindow(p, Point(width - 1, p.y())); + + Transaction t(csx); + writeRamBegin(); + + //Send data to write on GRAM + for(int i=0; i < length; i++) { + lsb = colors[i] & 0xFF; + msb = (colors[i] >> 8) & 0xFF; + + writeRam(msb); + writeRam(lsb); + } +} + +Color *DisplayGenericST7735::getScanLineBuffer() { + if(buffer == 0) buffer = new Color[getWidth()]; + return buffer; +} + +void DisplayGenericST7735::scanLineBuffer(Point p, unsigned short length) { + scanLine(p, buffer, length); +} + +void DisplayGenericST7735::drawImage(Point p, const ImageBase& img) { + short int xEnd = p.x() + img.getWidth() - 1; + short int yEnd = p.y() + img.getHeight() - 1; + if(xEnd >= width || yEnd >= height) { return; } + + const unsigned short *imgData = img.getData(); + if(imgData != 0) + { + unsigned char lsb = 0x00; + unsigned char msb = 0x00; + + //Optimized version for memory-loaded images + imageWindow(p, Point(xEnd, yEnd)); + int numPixels = img.getHeight() * img.getWidth(); + + Transaction t(csx); + writeRamBegin(); + + for(int i=0; i <= numPixels; i++) + { + lsb = imgData[i] & 0xFF; + msb = (imgData[i] >> 8) & 0xFF; + writeRam(msb); + writeRam(lsb); + } + } + else { img.draw(*this,p); } +} + +void DisplayGenericST7735::clippedDrawImage(Point p, Point a, Point b, const ImageBase& img) { + img.clippedDraw(*this,p,a,b); +} + +void DisplayGenericST7735::drawRectangle(Point a, Point b, Color c) { + line(a,Point(b.x(), a.y()), c); + line(Point(b.x(), a.y()), b, c); + line(b,Point(a.x(), b.y()), c); + line(Point(a.x(), b.y()), a, c); +} + +void DisplayGenericST7735::window(Point p1, Point p2, bool swap) { + #ifdef MXGUI_ORIENTATION_VERTICAL + char caset_offset = 2; + char raset_offset = 1; + #else //MXGUI_ORIENTATION_HORIZONTAL + char caset_offset = 1; + char raset_offset = 2; + #endif + + //Setting column bounds, ST7735_CASET (adding offset) + unsigned char buff_caset[4]; + buff_caset[0] = (p1.x()+caset_offset)>>8 & 255; + buff_caset[1] = (p1.x()+caset_offset) & 255; + buff_caset[2] = (p2.x()+caset_offset)>>8 & 255; + buff_caset[3] = (p2.x()+caset_offset) & 255; + + //Setting row bounds, ST7735_RASET (adding offset) + unsigned char buff_raset[4]; + buff_raset[0] = (p1.y()+raset_offset)>>8 & 255; + buff_raset[1] = (p1.y()+raset_offset) & 255; + buff_raset[2] = (p2.y()+raset_offset)>>8 & 255; + buff_raset[3] = (p2.y()+raset_offset) & 255; + + // For drawing texts, swap the caset and raset buffers + if (swap){ + writeReg(0x2A, buff_raset, sizeof(buff_raset)); + writeReg(0x2B, buff_caset, sizeof(buff_caset)); + } + else { + writeReg(0x2A, buff_caset, sizeof(buff_caset)); + writeReg(0x2B, buff_raset, sizeof(buff_raset)); + } +} + +void DisplayGenericST7735::update() { + // Useless for ST7735 display +} + +DisplayGenericST7735::pixel_iterator +DisplayGenericST7735::begin(Point p1, Point p2, IteratorDirection d) { + if(p1.x()<0 || p1.y()<0 || p2.x()<0 || p2.y()<0) { + return pixel_iterator(); + } + if(p1.x() >= width || p1.y() >= height || p2.x() >= width || p2.y() >= height) { + return pixel_iterator(); + } + if(p2.x() < p1.x() || p2.y() < p1.y()) { + return pixel_iterator(); + } + + if(d == DR) { textWindow(p1, p2); } + else { imageWindow(p1, p2); } + + Transaction t(csx); + writeRamBegin(); + + unsigned int numPixels = (p2.x() - p1.x() + 1) * (p2.y() - p1.y() + 1); + return pixel_iterator(numPixels); +} + +//Destructor +DisplayGenericST7735::~DisplayGenericST7735() { + if(buffer) delete[] buffer; +} + +//Constructor +DisplayGenericST7735::DisplayGenericST7735(GpioPin csx, GpioPin dcx, GpioPin resx) + : csx(csx), dcx(dcx), resx(resx), buffer(0) {} + +void DisplayGenericST7735::initialize() { + csx.high(); + dcx.high(); + + // POWER ON SEQUENCE: HW RESET -> SW RESET -> SLPOUT + resx.high(); + delayMs(150); + resx.low(); + delayMs(150); + resx.high(); + delayMs(150); + + writeReg(0x01); // ST7735_SWRESET + delayMs(150); + writeReg(0x11); // ST7735_SLPOUT + delayMs(150); + + sendCmds(initST7735b); + + doTurnOn(); + setFont(droid11); + setTextColor(make_pair(white, black)); +} + +/** + * Send commands of 8 bits to the MCU of the display. + */ +void DisplayGenericST7735::sendCmds(const unsigned char *cmds) { + while(*cmds) + { + unsigned char cmd = *cmds++; + unsigned char numArgs = *cmds++; + writeReg(cmd, cmds, numArgs); + cmds += numArgs; + delayUs(1); + } +} + +} //mxgui diff --git a/drivers/display_st7735.h b/drivers/display_st7735.h new file mode 100644 index 0000000000000000000000000000000000000000..d248460e8ef138b6014fdbb19741c23f9871c8be --- /dev/null +++ b/drivers/display_st7735.h @@ -0,0 +1,443 @@ +/*************************************************************************** + * Copyright (C) 2021 by Salaorni Davide, Velati Matteo * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * As a special exception, if other files instantiate templates or use * + * macros or inline functions from this file, or you compile this file * + * and link it with other works to produce a work based on this file, * + * this file does not by itself cause the resulting work to be covered * + * by the GNU General Public License. However the source code for this * + * file must still be made available in accordance with the GNU General * + * Public License. This exception does not invalidate any other reasons * + * why a work based on this file might be covered by the GNU General * + * Public License. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, see <http://www.gnu.org/licenses/> * + ***************************************************************************/ + +#pragma once + +#include <config/mxgui_settings.h> +#include "display.h" +#include "point.h" +#include "color.h" +#include "iterator_direction.h" +#include "miosix.h" +#include <cstdio> +#include <cstring> +#include <algorithm> + +namespace mxgui { + +#ifndef MXGUI_COLOR_DEPTH_16_BIT +#error The ST7735 driver requires a color depth 16 per pixel +#endif + +//Used to transiently pull low either the csx or dcx pin +class Transaction +{ +public: + Transaction(miosix::GpioPin pin) : pin(pin) { pin.low(); } + ~Transaction() { pin.high(); } +private: + miosix::GpioPin pin; +}; + +/** + * Generic driver for a ST7735 display. The SPI interface and mapping of the + * csx, dcx and resx pins is retargetable. + */ +class DisplayGenericST7735 : public Display +{ +public: + /** + * Turn the display On after it has been turned Off. + * Display initial state On. + */ + void doTurnOn() override; + + /** + * Turn the display Off. It can be later turned back On. + */ + void doTurnOff() override; + + /** + * Set display brightness. Depending on the underlying driver, + * may do nothing. + * \param brt from 0 to 100 + */ + void doSetBrightness(int brt) override; + + /** + * \return a pair with the display height and width + */ + std::pair<short int, short int> doGetSize() const override; + + /** + * Write text to the display. If text is too long it will be truncated + * \param p point where the upper left corner of the text will be printed + * \param text, text to print. + */ + void write(Point p, const char *text) override; + + /** + * Write part of text to the display + * \param p point of the upper left corner where the text will be drawn. + * Negative coordinates are allowed, as long as the clipped view has + * positive or zero coordinates + * \param a Upper left corner of clipping rectangle + * \param b Lower right corner of clipping rectangle + * \param text text to write + */ + void clippedWrite(Point p, Point a, Point b, const char *text) override; + + /** + * Clear the Display. The screen will be filled with the desired color + * \param color fill color + */ + void clear(Color color) override; + + /** + * Clear an area of the screen + * \param p1 upper left corner of area to clear + * \param p2 lower right corner of area to clear + * \param color fill color + */ + void clear(Point p1, Point p2, Color color) override; + + /** + * This member function is used on some target displays to reset the + * drawing window to its default value. You have to call beginPixel() once + * before calling setPixel(). You can then make any number of calls to + * setPixel() without calling beginPixel() again, as long as you don't + * call any other member function in this class. If you call another + * member function, for example line(), you have to call beginPixel() again + * before calling setPixel(). + */ + void beginPixel() override; + + /** + * Draw a pixel with desired color. + * \param p point where to draw pixel + * \param color pixel color + */ + void setPixel(Point p, Color color) override; + + /** + * Draw a line between point a and point b, with color c + * \param a first point + * \param b second point + * \param c line color + */ + void line(Point a, Point b, Color color) override; + + /** + * Draw an horizontal line on screen. + * Instead of line(), this member function takes an array of colors to be + * able to individually set pixel colors of a line. + * \param p starting point of the line + * \param colors an array of pixel colors whoase size must be b.x()-a.x()+1 + * \param length length of colors array. + * p.x()+length must be <= display.width() + */ + void scanLine(Point p, const Color *colors, unsigned short length) override; + + /** + * \return a buffer of length equal to this->getWidth() that can be used to + * render a scanline. + */ + Color *getScanLineBuffer() override; + + /** + * Draw the content of the last getScanLineBuffer() on an horizontal line + * on the screen. + * \param p starting point of the line + * \param length length of colors array. + * p.x()+length must be <= display.width() + */ + void scanLineBuffer(Point p, unsigned short length) override; + + /** + * Draw an image on the screen + * \param p point of the upper left corner where the image will be drawn + * \param i image to draw + */ + void drawImage(Point p, const ImageBase& img) override; + + /** + * Draw part of an image on the screen + * \param p point of the upper left corner where the image will be drawn. + * Negative coordinates are allowed, as long as the clipped view has + * positive or zero coordinates + * \param a Upper left corner of clipping rectangle + * \param b Lower right corner of clipping rectangle + * \param img Image to draw + */ + void clippedDrawImage(Point p, Point a, Point b, const ImageBase& img) override; + + /** + * Draw a rectangle (not filled) with the desired color + * \param a upper left corner of the rectangle + * \param b lower right corner of the rectangle + * \param c color of the line + */ + void drawRectangle(Point a, Point b, Color c) override; + + /** + * Make all changes done to the display since the last call to update() + * visible. + */ + void update() override; + + /** + * Pixel iterator. A pixel iterator is an output iterator that allows to + * define a window on the display and write to its pixels. + */ + class pixel_iterator + { + public: + /** + * Default constructor, results in an invalid iterator. + */ + pixel_iterator(): pixelLeft(0) {} + + /** + * Set a pixel and move the pointer to the next one + * \param color color to set the current pixel + * \return a reference to this + */ + pixel_iterator& operator= (Color color) + { + pixelLeft--; + + unsigned char lsb = color & 0xFF; + unsigned char msb = (color >> 8) & 0xFF; + + Transaction t(display->csx); + display->writeRam(msb); + display->writeRam(lsb); + + return *this; + } + + /** + * Compare two pixel_iterators for equality. + * They are equal if they point to the same location. + */ + bool operator== (const pixel_iterator& itr) + { + return this->pixelLeft==itr.pixelLeft; + } + + /** + * Compare two pixel_iterators for inequality. + * They different if they point to different locations. + */ + bool operator!= (const pixel_iterator& itr) + { + return this->pixelLeft!=itr.pixelLeft; + } + + /** + * \return a reference to this. + */ + pixel_iterator& operator* () { return *this; } + + /** + * \return a reference to this. Does not increment pixel pointer. + */ + pixel_iterator& operator++ () { return *this; } + + /** + * \return a reference to this. Does not increment pixel pointer. + */ + pixel_iterator& operator++ (int) { return *this; } + + /** + * Must be called if not all pixels of the required window are going + * to be written. + */ + void invalidate() {} + + private: + /** + * Constructor + * \param pixelLeft number of remaining pixels + */ + pixel_iterator(unsigned int pixelLeft): pixelLeft(pixelLeft) {} + + unsigned int pixelLeft; ///< How many pixels are left to draw + DisplayGenericST7735 *display; + + friend class DisplayGenericST7735; //Needs access to ctor + }; + + /** + * Specify a window on screen and return an object that allows to write + * its pixels. + * Note: a call to begin() will invalidate any previous iterator. + * \param p1 upper left corner of window + * \param p2 lower right corner (included) + * \param d increment direction + * \return a pixel iterator + */ + pixel_iterator begin(Point p1, Point p2, IteratorDirection d); + + /** + * \return an iterator which is one past the last pixel in the pixel + * specified by begin. Behaviour is undefined if called before calling + * begin() + */ + pixel_iterator end() const + { + // Default ctor: pixelLeft is zero + return pixel_iterator(); + } + + /** + * Destructor + */ + ~DisplayGenericST7735() override; + +protected: + + /** + * Constructor. + * \param csx chip select pin + * \param dcx data/command pin + * \param resx reset pin + */ + DisplayGenericST7735(miosix::GpioPin csx, + miosix::GpioPin dcx, + miosix::GpioPin resx); + + void initialize(); + + miosix::GpioPin csx; ///< Chip select + miosix::GpioPin dcx; ///< Data/Command + miosix::GpioPin resx; ///< Reset + +private: + + #if defined MXGUI_ORIENTATION_VERTICAL + static const short int width = 128; + static const short int height = 160; + #elif defined MXGUI_ORIENTATION_HORIZONTAL + static const short int width = 160; + static const short int height = 128; + #else + #error Orientation not defined + #endif + + /** + * Set cursor to desired location + * \param point where to set cursor (0<=x<=127, 0<=y<=159) + */ + inline void setCursor(Point p) + { + window(p, p, false); + } + + /** + * Register 0x36: MADCTL + * bit 7------0 + * 4: |||||+-- MH horizontal referesh (0 L-to-R, 1 R-to-L) + * 8: ||||+--- RGB BRG order (0 for RGB) + * 16: |||+---- ML vertical refesh (0 T-to-B, 1 B-to-T) + * 32: ||+----- MV row column exchange (1 for X-Y exchange) + * 64: |+------ MX column address order (1 for mirror X axis) + * 128: +------- MY row address order (1 for mirror Y axis) + */ + + /** + * Set a hardware window on the screen, optimized for writing text. + * The GRAM increment will be set to up-to-down first, then left-to-right + * which is the correct increment to draw fonts + * \param p1 upper left corner of the window + * \param p2 lower right corner of the window + */ + inline void textWindow(Point p1, Point p2) + { + #ifdef MXGUI_ORIENTATION_VERTICAL + writeReg (0x36, 0xE0); // MADCTL: MX + MY + MV + window(p1, p2, true); + #else //MXGUI_ORIENTATION_HORIZONTAL + writeReg (0x36, 0x80); // MADCTL: MY + window(p1, p2, true); + #endif + } + + /** + * Set a hardware window on the screen, optimized for drawing images. + * The GRAM increment will be set to left-to-right first, then up-to-down + * which is the correct increment to draw images + * \param p1 upper left corner of the window + * \param p2 lower right corner of the window + */ + inline void imageWindow(Point p1, Point p2) + { + #ifdef MXGUI_ORIENTATION_VERTICAL + writeReg (0x36, 0xC0); // MADCTL: MX + MY + window(p1, p2, false); + #else //MXGUI_ORIENTATION_HORIZONTAL + writeReg (0x36, 0xA0); // MADCTL: MY + MV + window(p1, p2, false); + #endif + } + + /** + * Common part of all window commands + */ + void window(Point p1, Point p2, bool swap); + + /** + * Sends command 0x2C to signal the start of data sending + */ + void writeRamBegin() + { + Transaction c(dcx); + writeRam(0x2C); //ST7735_RAMWR, to write the GRAM + } + + /** + * Used to send pixel data to the display's RAM, and also to send commands. + * The SPI chip select must be low before calling this member function + * \param data data to write + */ + virtual unsigned char writeRam(unsigned char data) = 0; + + /** + * Write data to a display register + * \param reg which register? + * \param data data to write + */ + virtual void writeReg(unsigned char reg, unsigned char data) = 0; + + /** + * Write data to a display register + * \param reg which register? + * \param data data to write, if null only reg will be written (zero arg cmd) + * \param len length of data, number of argument bytes + */ + virtual void writeReg(unsigned char reg, const unsigned char *data=0, int len=1) = 0; + + /** + * Send multiple commands to the display MCU (we use to send init sequence) + * \param cmds static array containing the commands + */ + void sendCmds(const unsigned char *cmds); + + Color *buffer; ///< For scanLineBuffer +}; + +} //namespace mxgui diff --git a/drivers/display_stm32f4discovery.cpp b/drivers/display_stm32f4discovery.cpp index fe75d081602d0b28efba0a328086cbca8435693d..d733182e3823891f38be96e77dfc70a7a2d2fe85 100644 --- a/drivers/display_stm32f4discovery.cpp +++ b/drivers/display_stm32f4discovery.cpp @@ -477,3 +477,848 @@ Color DisplayImpl::pixel_iterator::dummy; } //namespace mxgui #endif //_BOARD_STM32F429ZI_STM32F4DISCOVERY + +#ifdef _BOARD_STM32F469NI_STM32F469I_DISCO + +namespace mxgui { + +//Control interface + +//Pixel sync interface +typedef Gpio<GPIOF_BASE,10> en; +typedef Gpio<GPIOG_BASE, 7> dotclk; +typedef Gpio<GPIOA_BASE, 4> vsync; +typedef Gpio<GPIOC_BASE, 6> hsync; +//Pixel data bus +typedef Gpio<GPIOC_BASE,10> r0; //r2 +typedef Gpio<GPIOJ_BASE, 2> r1; //r3 +typedef Gpio<GPIOA_BASE,11> r2; //r4 +typedef Gpio<GPIOA_BASE,12> r3; //r5 +typedef Gpio<GPIOJ_BASE, 5> r4; //r6 +typedef Gpio<GPIOA_BASE, 6> g0; //g2 +typedef Gpio<GPIOG_BASE,10> g1; //g3 AF9 +typedef Gpio<GPIOJ_BASE,13> g2; //g4 AF9 +typedef Gpio<GPIOH_BASE, 4> g3; //g5 AF9 +typedef Gpio<GPIOC_BASE, 7> g4; //g6 +typedef Gpio<GPIOD_BASE, 3> g5; //g7 +typedef Gpio<GPIOD_BASE, 6> b0; //b2 +typedef Gpio<GPIOG_BASE,11> b1; //b3 +typedef Gpio<GPIOG_BASE,12> b2; //b4 AF9 +typedef Gpio<GPIOA_BASE, 3> b3; //b5 +typedef Gpio<GPIOB_BASE, 8> b4; //b6 + +void shortWrite(uint8_t param0, uint8_t param1) { + // Command FIFO Empty + while ((DSI->GPSR & DSI_GPSR_CMDFE) == 0); + + DSI->GHCR = (0x15 | // DSI_DCS_SHORT_PKT_WRITE_P1 + (0 << 6) | // Virtual Channel ID + (param0 << 8) | \ + (param1 << 16)); +} + +void longWrite(uint32_t numParams, uint32_t param0, uint8_t *pParams) { + // Command FIFO Empty + while ((DSI->GPSR & DSI_GPSR_CMDFE) == 0); + + uint32_t uicounter = 0; + while (uicounter < numParams) { + if (uicounter == 0x00) { + DSI->GPDR = (param0 | \ + ((*(pParams+uicounter)) << 8) | \ + ((*(pParams+uicounter+1)) << 16) | \ + ((*(pParams+uicounter+2)) << 24)); + uicounter += 3; + } else { + DSI->GPDR = ((*(pParams+uicounter)) | \ + ((*(pParams+uicounter+1)) << 8) | \ + ((*(pParams+uicounter+2)) << 16) | \ + ((*(pParams+uicounter+3)) << 24)); + uicounter += 4; + } + } + + DSI->GHCR = (0x39 | // DSI_DCS_LONG_PKT_WRITE + (0 << 6) | // Virtual Channel Id + (((numParams+1)&0x00FF) << 8) | \ + ((((numParams+1)&0xFF00) >> 8) << 16)); +} + +void sendCmd(uint32_t numParams, uint8_t *pParams) { + if (numParams <= 1) { + shortWrite(pParams[0], pParams[1]); + } else { + longWrite(numParams, pParams[numParams], pParams); + } +} + +void registerDisplayHook(DisplayManager& dm) +{ + dm.registerDisplay(&DisplayImpl::instance()); +} + +// +// class DisplayImpl +// + +DisplayImpl& DisplayImpl::instance() +{ + static DisplayImpl instance; + return instance; +} + +void DisplayImpl::doTurnOn() +{ + LTDC->GCR |= LTDC_GCR_LTDCEN; + Thread::sleep(40); + uint8_t set_display_on[] = {0x29, 0x00}; + sendCmd(0, set_display_on); +} + +void DisplayImpl::doTurnOff() +{ + uint8_t set_display_off[] = {0x28, 0x00}; + sendCmd(0, set_display_off); + LTDC->GCR &= ~LTDC_GCR_LTDCEN; +} + +void DisplayImpl::doSetBrightness(int brt) {} + +pair<short int, short int> DisplayImpl::doGetSize() const +{ + return make_pair(height,width); +} + +void DisplayImpl::write(Point p, const char *text) +{ + font.draw(*this,textColor,p,text); +} + +void DisplayImpl::clippedWrite(Point p, Point a, Point b, const char *text) +{ + font.clippedDraw(*this,textColor,p,a,b,text); +} + +void DisplayImpl::clear(Color color) +{ + clear(Point(0,0),Point(width-1,height-1),color); +} + +void DisplayImpl::clear(Point p1, Point p2, Color color) +{ + if(p1.x()<0 || p2.x()<p1.x() || p2.x()>=width + ||p1.y()<0 || p2.y()<p1.y() || p2.y()>=height) return; + if((color & 0xff)==(color>>8)) + { + //Can use memset + if(p1.x()==0 && p2.x()==width-1) + { + //Can merge lines + memset(framebuffer1+p1.y()*width,color,(p2.y()-p1.y()+1)*width*bpp); + } else { + //Can't merge lines + Color *ptr=framebuffer1+p1.x()+width*p1.y(); + short len=p2.x()-p1.x()+1; + for(short i=p1.y();i<=p2.y();i++) + { + memset(ptr,color,len*bpp); + ptr+=width; + } + } + } else { + //Can't use memset + if(p1.x()==0 && p2.x()==width-1) + { + //Can merge lines + Color *ptr=framebuffer1+p1.y()*width; + int numPixels=(p2.y()-p1.y()+1)*width; + //This loop is worth unrolling + for(int i=0;i<numPixels/4;i++) + { + *ptr++=color; + *ptr++=color; + *ptr++=color; + *ptr++=color; + } + for(int i=0;i<(numPixels & 3);i++) *ptr++=color; + } else { + //Can't merge lines + Color *ptr=framebuffer1+p1.x()+width*p1.y(); + short len=p2.x()-p1.x()+1; + for(short i=p1.y();i<=p2.y();i++) + { + for(short j=0;j<len;j++) *ptr++=color; + ptr+=width-len; + } + } + } +} + +void DisplayImpl::beginPixel() {} + +void DisplayImpl::setPixel(Point p, Color color) +{ + int offset=p.x()+p.y()*width; + if(offset<0 || offset>=numPixels) return; + *(framebuffer1+offset)=color; +} + +void DisplayImpl::line(Point a, Point b, Color color) +{ + //Horizontal line speed optimization + if(a.y()==b.y()) + { + short minx=min(a.x(),b.x()); + short maxx=max(a.x(),b.x()); + if(minx<0 || maxx>=width || a.y()<0 || a.y()>=height) return; + Color *ptr=framebuffer1+minx+width*a.y(); + for(short i=minx;i<=maxx;i++) *ptr++=color; + return; + } + //Vertical line speed optimization + if(a.x()==b.x()) + { + short miny=min(a.y(),b.y()); + short maxy=max(a.y(),b.y()); + if(a.x()<0 || a.x()>=width || miny<0 || maxy>=height) return; + Color *ptr=framebuffer1+a.x()+width*miny; + for(short i=miny;i<=maxy;i++) + { + *ptr=color; + ptr+=width; + } + return; + } + //General case + Line::draw(*this,a,b,color); +} + +void DisplayImpl::scanLine(Point p, const Color *colors, unsigned short length) +{ + if(p.x()<0 || static_cast<int>(p.x())+static_cast<int>(length)>width + ||p.y()<0 || p.y()>=height) return; + Color *ptr=framebuffer1+p.x()+p.y()*width; + memcpy(ptr,colors,length*bpp); +} + +Color *DisplayImpl::getScanLineBuffer() +{ + return buffer; +} + +void DisplayImpl::scanLineBuffer(Point p, unsigned short length) +{ + int offset=p.x()+p.y()*width; + if(offset<0 || offset>=numPixels) return; + memcpy(framebuffer1+offset,buffer,length*bpp); +} + +void DisplayImpl::drawImage(Point p, const ImageBase& img) +{ + short int xEnd=p.x()+img.getWidth()-1; + short int yEnd=p.y()+img.getHeight()-1; + if(p.x()<0 || p.y()<0 || xEnd<p.x() || yEnd<p.y() + ||xEnd >= width || yEnd >= height) return; + +// const unsigned short *imgData=img.getData(); +// if(imgData!=0) +// { +// //TODO Optimized version for in-memory images +// } else + img.draw(*this,p); +} + +void DisplayImpl::clippedDrawImage(Point p, Point a, Point b, const ImageBase& img) +{ +// if(img.getData()==0) +// { + img.clippedDraw(*this,p,a,b); + return; +// } //else optimized version for memory-loaded images +// //TODO: optimize +// } +} + +void DisplayImpl::drawRectangle(Point a, Point b, Color c) +{ + line(a,Point(b.x(),a.y()),c); + line(Point(b.x(),a.y()),b,c); + line(b,Point(a.x(),b.y()),c); + line(Point(a.x(),b.y()),a,c); +} + +void DisplayImpl::update() +{ + DSI->WCR |= DSI_WCR_LTDCEN; +} + +DisplayImpl::pixel_iterator DisplayImpl::begin(Point p1, Point p2, + IteratorDirection d) +{ + bool fail=false; + if(p1.x()<0 || p1.y()<0 || p2.x()<0 || p2.y()<0) fail=true; + if(p1.x()>=width || p1.y()>=height || p2.x()>=width || p2.y()>=height) fail=true; + if(p2.x()<p1.x() || p2.y()<p1.y()) fail=true; + if(fail) + { + //Return invalid (dummy) iterators + this->last=pixel_iterator(); + return this->last; + } + + //Set the last iterator to a suitable one-past-the last value + if(d==DR) this->last=pixel_iterator(Point(p2.x()+1,p1.y()),p2,d,this); + else this->last=pixel_iterator(Point(p1.x(),p2.y()+1),p2,d,this); + + return pixel_iterator(p1,p2,d,this); +} + +DisplayImpl::~DisplayImpl() {} + +DisplayImpl::DisplayImpl() + : framebuffer1(reinterpret_cast<unsigned short *>(0xc0c00000)), + buffer(framebuffer1 + numPixels) +{ + /* This driver uses DSI interface in command mode, but it was firstly programmed in video mode. + * For this reason some instructions are still there but they don't actually affect the driver. + * For example these timing parameters are important in video mode, but in command mode they can + * take any value and the display still works. + */ + const unsigned int hsync = 12; // hsync timing + const unsigned int vsync = 120; // vsync timing + const unsigned int hbp = 12; // horizontal back porch + const unsigned int vbp = 120; // vertical back porch + const unsigned int hfp = 12; // horizontal front porch + const unsigned int vfp = 120; // vertical front porch + enum { + ARGB8888 = 0, + RGB888 = 1, + RGB565 = 2, + ARGB1555 = 3, + ARGB4444 = 4, + L8 = 5, + AL44 = 6, + AL88 = 7 + }; + + // Parameters for DSI PLL + // These values assume HSE oscillator is 8 MHz and system clock is 168 MHz + #if HSE_VALUE != 8000000 + #error The display driver requires an HSE oscillator running at 8 MHz + #endif + const unsigned int IDF = 4; // must be in the range 1..7 + const unsigned int ODF = 1; // must be in the set {1, 2, 4, 8} + const unsigned int NDIV = 125; // must be in the range 10..125 + const unsigned int F_VCO = (HSE_VALUE/IDF)*2*NDIV; // 500 MHz - must be between 500 and 1000 MHz + const unsigned int F_PHY_MHz = (F_VCO/(2*ODF))/1000000; // 250 MHz - HS clock for D-PHY must be between 80 and 500 MHz + const unsigned int lane_byte_clk = F_VCO/(2*ODF*8); // 31,25 MHz - must be no more than 62,5 MHz + const unsigned int TXECLKDIV = 2; // must be at least 2 and ensure lane_byte_clk/TXECLKDIV <= 20 MHz + const unsigned int pixel_clock = F_VCO/bpp; // 31,25 MHz + const unsigned int clock_ratio = lane_byte_clk/pixel_clock; + + memset(framebuffer1, 0, height*width*bpp); + + // Reset of screen by active low on GPIO PH7 + typedef Gpio<GPIOH_BASE, 7> reset; + reset::mode(Mode::OUTPUT); + reset::speed(Speed::_100MHz); + reset::low(); + Thread::sleep(20); + reset::high(); + Thread::sleep(10); + + // Enable clock for DSI and LTDC then force their reset + { + FastInterruptDisableLock dLock; + + en::mode(Mode::ALTERNATE); en::alternateFunction(14); en::speed(Speed::_100MHz); + dotclk::mode(Mode::ALTERNATE); dotclk::alternateFunction(14); dotclk::speed(Speed::_100MHz); + vsync::mode(Mode::ALTERNATE); vsync::alternateFunction(14); vsync::speed(Speed::_100MHz); + hsync::mode(Mode::ALTERNATE); hsync::alternateFunction(14); hsync::speed(Speed::_100MHz); + r0::mode(Mode::ALTERNATE); r0::alternateFunction(14); r0::speed(Speed::_100MHz); + r1::mode(Mode::ALTERNATE); r1::alternateFunction(14); r1::speed(Speed::_100MHz); + r2::mode(Mode::ALTERNATE); r2::alternateFunction(14); r2::speed(Speed::_100MHz); + r3::mode(Mode::ALTERNATE); r3::alternateFunction(14); r3::speed(Speed::_100MHz); + r4::mode(Mode::ALTERNATE); r4::alternateFunction(14); r4::speed(Speed::_100MHz); + g0::mode(Mode::ALTERNATE); g0::alternateFunction(14); g0::speed(Speed::_100MHz); + g1::mode(Mode::ALTERNATE); g1::alternateFunction(9); g1::speed(Speed::_100MHz); + g2::mode(Mode::ALTERNATE); g2::alternateFunction(9); g2::speed(Speed::_100MHz); + g3::mode(Mode::ALTERNATE); g3::alternateFunction(9); g3::speed(Speed::_100MHz); + g4::mode(Mode::ALTERNATE); g4::alternateFunction(14); g4::speed(Speed::_100MHz); + g5::mode(Mode::ALTERNATE); g5::alternateFunction(14); g5::speed(Speed::_100MHz); + b0::mode(Mode::ALTERNATE); b0::alternateFunction(14); b0::speed(Speed::_100MHz); + b1::mode(Mode::ALTERNATE); b1::alternateFunction(14); b1::speed(Speed::_100MHz); + b2::mode(Mode::ALTERNATE); b2::alternateFunction(9); b2::speed(Speed::_100MHz); + b3::mode(Mode::ALTERNATE); b3::alternateFunction(14); b3::speed(Speed::_100MHz); + b4::mode(Mode::ALTERNATE); b4::alternateFunction(14); b4::speed(Speed::_100MHz); + + RCC->APB2ENR |= RCC_APB2ENR_LTDCEN; + RCC_SYNC(); + RCC->APB2ENR |= RCC_APB2ENR_DSIEN; + RCC_SYNC(); + + RCC->APB2RSTR |= RCC_APB2RSTR_LTDCRST; + RCC->APB2RSTR &= ~RCC_APB2RSTR_LTDCRST; + + RCC->APB2RSTR |= RCC_APB2RSTR_DSIRST; + RCC->APB2RSTR &= ~RCC_APB2RSTR_DSIRST; + } + + // Configure PLLSAI for LTDC, turn it ON and wait for its lock + { + FastInterruptDisableLock dLock; + + // LTDC clock depends on PLL_M which is fixed at boot with value 8 + // It also depends on PLLSAI which can be freely configured + const unsigned int PLLSAI_N = 384; + const unsigned int PLLSAI_R = 7; + //const unsigned int PLLSAI_DIVR = 0; + + // Input VCO Frequency = HSE_VALUE/PPL_M must be between 1 and 2 MHz, so 8/8 = 1 MHz + // N must be in the range 50..432 and ensure a frequency between 100 and 432 MHz + // if N = 384 then 1 MHz * 384 = 384 MHz + // R must be in the range 2..7, we choose R = 7 so 384/7 = 54,857 MHz + // and then we divide it by 2 (setting DIVR to 0) to obtain 27,428 Mhz + + // Read PLLSAI_P and PLLSAI_Q values from PLLSAICFGR register + uint32_t PLLSAI_P = ((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIP) >> 16); + uint32_t PLLSAI_Q = ((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIQ) >> 24); + // PLLSAI_VCO_Input = PLL_SOURCE/PLL_M + // PLLSAI_VCO_Output = PLLSAI_VCO_Input * PLLSAI_N + // LTDC_CLK(first level) = PLLSAI_VCO_Output/PLLSAI_R + RCC->PLLSAICFGR = (PLLSAI_N << 6) | \ + (PLLSAI_P << 16) | \ + (PLLSAI_Q << 24) | \ + (PLLSAI_R << 28); + // LTDC_CLK = LTDC_CLK(first level)/PLLSAI_DIVR + RCC->DCKCFGR = RCC->DCKCFGR & ~RCC_DCKCFGR_PLLSAIDIVR; + + RCC->CR |= RCC_CR_PLLSAION; + } + while ((RCC->CR & RCC_CR_PLLSAIRDY) == 0); + + /* Start LTDC configuration */ + // Configure timings + LTDC->SSCR = (hsync-1) << 16 | (vsync-1); + LTDC->BPCR = (hsync+hbp-1) << 16 | (vsync+vbp-1); + LTDC->AWCR = (hsync+hbp+width-1) << 16 | (vsync+vbp+height-1); + LTDC->TWCR = (hsync+hbp+width+hfp-1) << 16 | (vsync+vbp+height+vfp-1); + + // Configure polarities (everything active high except data enabled) + LTDC->GCR |= (LTDC_GCR_HSPOL | LTDC_GCR_VSPOL | LTDC_GCR_DEPOL | LTDC_GCR_PCPOL); + LTDC->GCR &= ~LTDC_GCR_DEPOL; + + // Configure background color + LTDC->BCCR = 0; + + // Configure the layer + // Horizontal start and stop position + LTDC_Layer1->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS); + LTDC_Layer1->WHPCR = ((hsync+hbp+width-1) << 16) | (hsync+hbp); + // Vertical start and stop position + LTDC_Layer1->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS); + LTDC_Layer1->WVPCR = ((vsync+vbp+height-1) << 16) | (vsync+vbp); + // Pixel format + LTDC_Layer1->PFCR &= ~(LTDC_LxPFCR_PF); + LTDC_Layer1->PFCR |= RGB565; + // Color frame buffer start address + LTDC_Layer1->CFBAR &= ~(LTDC_LxCFBAR_CFBADD); + LTDC_Layer1->CFBAR = reinterpret_cast<unsigned int>(framebuffer1); + // Color frame buffer pitch in byte (multiply by 2 for RGB565) + LTDC_Layer1->CFBLR &= ~(LTDC_LxCFBLR_CFBP | LTDC_LxCFBLR_CFBLL); + LTDC_Layer1->CFBLR = (width*2) << 16 | (width*2+3); + // Frame buffer line number + LTDC_Layer1->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR); + LTDC_Layer1->CFBLNR = height; + // Default color values (black with no alpha) + LTDC_Layer1->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA); + LTDC_Layer1->DCCR = 0; + // Specifies the constant alpha value + LTDC_Layer1->CACR &= ~(LTDC_LxCACR_CONSTA); + LTDC_Layer1->CACR = 255; + // Blending factors (constant alpha) + LTDC_Layer1->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1); + LTDC_Layer1->BFCR = (0x400 | 0x5); + // Enable layer + LTDC_Layer1->CR |= LTDC_LxCR_LEN; + + // If needed enable dithering and color keying + LTDC_Layer1->CKCR = 0; + + // Reload shadow registers + LTDC->SRCR |= LTDC_SRCR_IMR; + + // Finally enable the display + LTDC->GCR |= LTDC_GCR_LTDCEN; + /* End LTDC configuration */ + + /* Start DSI configuration */ + // Turn on the DSI regulator and wait for the regulator ready + DSI->WRPCR |= DSI_WRPCR_REGEN; + while ((DSI->WISR & DSI_WISR_RRS) == 0); + + // Configure the DSI PLL, turn it ON and wait for its lock + // F_VCO = (HSE_VALUE / IDF) * 2 * NDIV + // Lane_Byte_CLK = F_VCO / (2 * ODF * 8) + // F_VCO must be in the range from 500 MHz to 1 GHz + // To obtain 500 Mbit/s rate, Lane_Byte_CLK must be 31,25 MHz + // Since HSE_VALUE = 8 MHz this is possible with NDIV = 125, IDF = 4, ODF = 1 + DSI->WRPCR &= ~(DSI_WRPCR_PLL_NDIV | DSI_WRPCR_PLL_IDF | DSI_WRPCR_PLL_ODF); + DSI->WRPCR |= ((NDIV << 2) | (IDF << 11) | (ODF << 16)); + DSI->WRPCR |= DSI_WRPCR_PLLEN; + while ((DSI->WISR & DSI_WISR_PLLLS) == 0); + + // Configure the D-PHY parameters + // Calculate the bit period in high-speed mode in unit of 0.25 ns (UIX4) + // The equation is: UIX4 = IntegerPart( (1000/F_PHY_MHz) * 4 ) + // Where: F_PHY_MHz = (NDIV * HSE_MHz) / (IDF * ODF) + DSI->WPCR[0] &= ~DSI_WPCR0_UIX4; + DSI->WPCR[0] |= (1000/F_PHY_MHz)*4; + // Disable all error interrupts and reset the Error Mask + DSI->IER[0] = 0; + DSI->IER[1] = 0; + // Configure the number of active data lanes (just one out of two for 16 bpp) + DSI->PCONFR &= ~DSI_PCONFR_NL; + DSI->PCONFR |= 1; + // Set automatic clock lane control + DSI->CLCR |= (DSI_CLCR_DPCC | DSI_CLCR_ACR); + // Time for LP/HS and HS/LP transitions for both clock lane and data lanes + DSI->CLTCR |= (40 << 16) // HS to LP + | (40 << 0); // LP to HS + DSI->DLTCR |= (20 << 24) // HS to LP + | (20 << 16); // HS to LP + // Stop wait time (don't know how much should it be, random high number in 8 bit) + DSI->PCONFR &= ~DSI_PCONFR_SW_TIME; + DSI->PCONFR |= (100 << 8); + + // Configure the DSI Host timing + //DSI->CCR |= (... << 8); // timeout clock configuration non dice nulla... + // Configure clock speed for low-power mode + DSI->CCR &= ~DSI_CCR_TXECKDIV; + DSI->CCR |= TXECLKDIV; + + // Configure the DSI Host flow control and DBI interface + DSI->PCR &= ~(DSI_PCR_CRCRXE | DSI_PCR_ECCRXE | DSI_PCR_BTAE | DSI_PCR_ETRXE | DSI_PCR_ETTXE); + DSI->GVCIDR &= ~DSI_GVCIDR_VCID; // set Virtual Channel ID = 0 for the display + + // Configure the DSI Host LTDC interface + DSI->LVCIDR &= ~3; // Virtual channel ID for LTDC interface traffic + DSI->LCOLCR &= ~DSI_LCOLCR_COLC; + DSI->LCOLCR |= RGB565; // Color coding for the host + DSI->WCFGR &= ~DSI_WCFGR_COLMUX; + DSI->WCFGR |= RGB565 << 1; // Color coding for the wrapper + DSI->LPCR &= ~(DSI_LPCR_DEP | DSI_LPCR_VSP | DSI_LPCR_HSP); + DSI->LPCR |= (DSI_LPCR_DEP | 0 | 0); // Polarity of control signals: same of LTDC except for DE + DSI->WCFGR |= DSI_WCFGR_VSPOL; // LTDC halts at VSYNC rising edge + + // Configure the DSI Host for command mode + // Select command mode by setting CMDM and DSIM bits + DSI->MCR |= DSI_MCR_CMDM; + DSI->WCFGR |= DSI_WCFGR_DSIM; + // Configure the maximum allowed size for write memory command + DSI->LCCR &= ~DSI_LCCR_CMDSIZE; + DSI->LCCR |= width; + + DSI->VMCR |= 0x3f << 8; // LP allowed in all video periods + DSI->VMCR &= ~DSI_VMCR_FBTAAE; // Do not request acknowledge at end of frame (at this time) + DSI->VMCR |= DSI_VMCR_LPCE; // Allow commands in LP + DSI->VPCR |= width; // Video packet size + DSI->VCCR = 0; // Chunks number to be transmitted through the DSI link + DSI->VNPCR |= 0xFFF; // Size of the null packet + // Timings in lane byte clock cycles + DSI->VLCR |= (hsync + hbp + width + hfp)*clock_ratio; + DSI->VHSACR |= hsync*clock_ratio; + DSI->VHBPCR |= hbp*clock_ratio; + DSI->VVSACR |= vsync; + DSI->VVBPCR |= vbp; + DSI->VVFPCR |= vfp; + DSI->VVACR |= height; + DSI->LPMCR |= (64 << 16); // Low power largest packet size + DSI->LPMCR |= 64; // Low power VACT largest packet size + // Command trasmission only in low power mode + DSI->CMCR |= (DSI_CMCR_GSW0TX | \ + DSI_CMCR_GSW1TX | \ + DSI_CMCR_GSW2TX | \ + DSI_CMCR_GSR0TX | \ + DSI_CMCR_GSR1TX | \ + DSI_CMCR_GSR2TX | \ + DSI_CMCR_GLWTX | \ + DSI_CMCR_DSW0TX | \ + DSI_CMCR_DSW1TX | \ + DSI_CMCR_DSR0TX | \ + DSI_CMCR_DLWTX | \ + DSI_CMCR_MRDPS); + + // Configure the acknowledge request after each packet transmission + DSI->CMCR |= DSI_CMCR_ARE; + + // Enable the D-PHY data lane + DSI->PCTLR |= DSI_PCTLR_DEN; + + // Enable the D-PHY clock lane + DSI->PCTLR |= DSI_PCTLR_CKE; + + // Enable the DSI Host + DSI->CR |= DSI_CR_EN; + + // Enable the DSI wrapper + DSI->WCR |= DSI_WCR_DSIEN; + /* End DSI configuration */ + + // Send DCS commands through the APB generic interface to configure the display + /* OTM8009A power up sequence */ + const uint8_t lcdRegData1[] = {0x80,0x09,0x01,0xFF}; + const uint8_t lcdRegData2[] = {0x80,0x09,0xFF}; + const uint8_t lcdRegData3[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01,0xE1}; + const uint8_t lcdRegData4[] = {0x00,0x09,0x0F,0x0E,0x07,0x10,0x0B,0x0A,0x04,0x07,0x0B,0x08,0x0F,0x10,0x0A,0x01,0xE2}; + const uint8_t lcdRegData5[] = {0x79,0x79,0xD8}; + const uint8_t lcdRegData6[] = {0x00,0x01,0xB3}; + const uint8_t lcdRegData7[] = {0x85,0x01,0x00,0x84,0x01,0x00,0xCE}; + const uint8_t lcdRegData8[] = {0x18,0x04,0x03,0x39,0x00,0x00,0x00,0x18,0x03,0x03,0x3A,0x00,0x00,0x00,0xCE}; + const uint8_t lcdRegData9[] = {0x18,0x02,0x03,0x3B,0x00,0x00,0x00,0x18,0x01,0x03,0x3C,0x00,0x00,0x00,0xCE}; + const uint8_t lcdRegData10[] = {0x01,0x01,0x20,0x20,0x00,0x00,0x01,0x02,0x00,0x00,0xCF}; + const uint8_t lcdRegData11[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData12[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData13[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData14[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData15[] = {0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData16[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x04,0x04,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData17[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCB}; + const uint8_t lcdRegData18[] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xCB}; + const uint8_t lcdRegData19[] = {0x00,0x26,0x09,0x0B,0x01,0x25,0x00,0x00,0x00,0x00,0xCC}; + const uint8_t lcdRegData20[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x26,0x0A,0x0C,0x02,0xCC}; + const uint8_t lcdRegData21[] = {0x25,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC}; + const uint8_t lcdRegData22[] = {0x00,0x25,0x0C,0x0A,0x02,0x26,0x00,0x00,0x00,0x00,0xCC}; + const uint8_t lcdRegData23[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x25,0x0B,0x09,0x01,0xCC}; + const uint8_t lcdRegData24[] = {0x26,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xCC}; + const uint8_t lcdRegData25[] = {0xFF,0xFF,0xFF,0xFF}; + + /* + * CASET value (Column Address Set): X direction LCD GRAM boundaries depending on LCD orientation mode + * PASET value (Page Address Set): Y direction LCD GRAM boundaries depending on LCD orientation mode + * + * XS[15:0] = 0x000 = 0, XE[15:0] = 0x31F = 799 for landscape mode: apply to CASET + * YS[15:0] = 0x000 = 0, YE[15:0] = 0x31F = 799 for portrait mode: apply to PASET + * + * XS[15:0] = 0x000 = 0, XE[15:0] = 0x1DF = 479 for portrait mode: apply to CASET + * YS[15:0] = 0x000 = 0, YE[15:0] = 0x1DF = 479 for landscape mode: apply to PASET + */ + +// #if defined MXGUI_ORIENTATION_VERTICAL +// const uint8_t lcdRegData27[] = {0x00, 0x00, 0x03, 0x1F, 0x2B}; +// const uint8_t lcdRegData28[] = {0x00, 0x00, 0x01, 0xDF, 0x2A}; +// #elif defined MXGUI_ORIENTATION_HORIZONTAL +// const uint8_t lcdRegData27[] = {0x00, 0x00, 0x03, 0x1F, 0x2A}; +// const uint8_t lcdRegData28[] = {0x00, 0x00, 0x01, 0xDF, 0x2B}; +// #endif + + const uint8_t ShortRegData1[] = {0x00, 0x00}; + const uint8_t ShortRegData2[] = {0x00, 0x80}; + const uint8_t ShortRegData3[] = {0xC4, 0x30}; + const uint8_t ShortRegData4[] = {0x00, 0x8A}; + const uint8_t ShortRegData5[] = {0xC4, 0x40}; + const uint8_t ShortRegData6[] = {0x00, 0xB1}; + const uint8_t ShortRegData7[] = {0xC5, 0xA9}; + const uint8_t ShortRegData8[] = {0x00, 0x91}; + const uint8_t ShortRegData9[] = {0xC5, 0x34}; + const uint8_t ShortRegData10[] = {0x00, 0xB4}; + const uint8_t ShortRegData11[] = {0xC0, 0x50}; + const uint8_t ShortRegData12[] = {0xD9, 0x4E}; + const uint8_t ShortRegData13[] = {0x00, 0x81}; + const uint8_t ShortRegData14[] = {0xC1, 0x66}; + const uint8_t ShortRegData15[] = {0x00, 0xA1}; + const uint8_t ShortRegData16[] = {0xC1, 0x08}; + const uint8_t ShortRegData17[] = {0x00, 0x92}; + const uint8_t ShortRegData18[] = {0xC5, 0x01}; + const uint8_t ShortRegData19[] = {0x00, 0x95}; + const uint8_t ShortRegData20[] = {0x00, 0x94}; + const uint8_t ShortRegData21[] = {0xC5, 0x33}; + const uint8_t ShortRegData22[] = {0x00, 0xA3}; + const uint8_t ShortRegData23[] = {0xC0, 0x1B}; + const uint8_t ShortRegData24[] = {0x00, 0x82}; + const uint8_t ShortRegData25[] = {0xC5, 0x83}; + const uint8_t ShortRegData26[] = {0xC4, 0x83}; + const uint8_t ShortRegData27[] = {0xC1, 0x0E}; + const uint8_t ShortRegData28[] = {0x00, 0xA6}; + const uint8_t ShortRegData29[] = {0x00, 0xA0}; + const uint8_t ShortRegData30[] = {0x00, 0xB0}; + const uint8_t ShortRegData31[] = {0x00, 0xC0}; + const uint8_t ShortRegData32[] = {0x00, 0xD0}; + const uint8_t ShortRegData33[] = {0x00, 0x90}; + const uint8_t ShortRegData34[] = {0x00, 0xE0}; + const uint8_t ShortRegData35[] = {0x00, 0xF0}; + const uint8_t ShortRegData36[] = {0x11, 0x00}; + const uint8_t ShortRegData37[] = {0x3A, 0x55}; +// const uint8_t ShortRegData38[] = {0x3A, 0x77}; + +// #if defined MXGUI_ORIENTATION_VERTICAL +// const uint8_t ShortRegData39[] = {0x36, 0x00}; +// #elif defined MXGUI_ORIENTATION_HORIZONTAL +// const uint8_t ShortRegData39[] = {0x36, 0x60}; +// #endif + + const uint8_t ShortRegData40[] = {0x51, 0xFF}; /* Draupner: Brightness changed from 0x7F */ + const uint8_t ShortRegData41[] = {0x53, 0x2C}; + const uint8_t ShortRegData42[] = {0x55, 0x02}; + const uint8_t ShortRegData43[] = {0x5E, 0xFF}; + const uint8_t ShortRegData44[] = {0x29, 0x00}; + const uint8_t ShortRegData45[] = {0x2C, 0x00}; + const uint8_t ShortRegData46[] = {0xCF, 0x00}; + const uint8_t ShortRegData47[] = {0xC5, 0x66}; + const uint8_t ShortRegData48[] = {0x00, 0xB6}; + const uint8_t ShortRegData49[] = {0xF5, 0x06}; + + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(3, (uint8_t *)lcdRegData1); + sendCmd(0, (uint8_t *)ShortRegData2); + sendCmd(2, (uint8_t *)lcdRegData2); + sendCmd(0, (uint8_t *)ShortRegData2); + sendCmd(0, (uint8_t *)ShortRegData3); + Thread::sleep(10); + sendCmd(0, (uint8_t *)ShortRegData4); + sendCmd(0, (uint8_t *)ShortRegData5); + Thread::sleep(10); + sendCmd(0, (uint8_t *)ShortRegData6); + sendCmd(0, (uint8_t *)ShortRegData7); + sendCmd(0, (uint8_t *)ShortRegData8); + sendCmd(0, (uint8_t *)ShortRegData9); + sendCmd(0, (uint8_t *)ShortRegData10); + sendCmd(0, (uint8_t *)ShortRegData11); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(0, (uint8_t *)ShortRegData12); + sendCmd(0, (uint8_t *)ShortRegData13); + sendCmd(0, (uint8_t *)ShortRegData14); + sendCmd(0, (uint8_t *)ShortRegData15); + sendCmd(0, (uint8_t *)ShortRegData16); + sendCmd(0, (uint8_t *)ShortRegData17); + sendCmd(0, (uint8_t *)ShortRegData18); + sendCmd(0, (uint8_t *)ShortRegData19); + sendCmd(0, (uint8_t *)ShortRegData9); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(2, (uint8_t *)lcdRegData5); + sendCmd(0, (uint8_t *)ShortRegData20); + sendCmd(0, (uint8_t *)ShortRegData21); + sendCmd(0, (uint8_t *)ShortRegData22); + sendCmd(0, (uint8_t *)ShortRegData23); + sendCmd(0, (uint8_t *)ShortRegData24); + sendCmd(0, (uint8_t *)ShortRegData25); + sendCmd(0, (uint8_t *)ShortRegData13); + sendCmd(0, (uint8_t *)ShortRegData26); + sendCmd(0, (uint8_t *)ShortRegData15); + sendCmd(0, (uint8_t *)ShortRegData27); + sendCmd(0, (uint8_t *)ShortRegData28); + sendCmd(2, (uint8_t *)lcdRegData6); + sendCmd(0, (uint8_t *)ShortRegData2); + sendCmd(6, (uint8_t *)lcdRegData7); + sendCmd(0, (uint8_t *)ShortRegData29); + sendCmd(14, (uint8_t *)lcdRegData8); + sendCmd(0, (uint8_t *)ShortRegData30); + sendCmd(14, (uint8_t *)lcdRegData9); + sendCmd(0, (uint8_t *)ShortRegData31); + sendCmd(10, (uint8_t *)lcdRegData10); + sendCmd(0, (uint8_t *)ShortRegData32); + sendCmd(0, (uint8_t *)ShortRegData46); + sendCmd(0, (uint8_t *)ShortRegData2); + sendCmd(10, (uint8_t *)lcdRegData11); + sendCmd(0, (uint8_t *)ShortRegData33); + sendCmd(15, (uint8_t *)lcdRegData12); + sendCmd(0, (uint8_t *)ShortRegData29); + sendCmd(15, (uint8_t *)lcdRegData13); + sendCmd(0, (uint8_t *)ShortRegData30); + sendCmd(10, (uint8_t *)lcdRegData14); + sendCmd(0, (uint8_t *)ShortRegData31); + sendCmd(15, (uint8_t *)lcdRegData15); + sendCmd(0, (uint8_t *)ShortRegData32); + sendCmd(15, (uint8_t *)lcdRegData16); + sendCmd(0, (uint8_t *)ShortRegData34); + sendCmd(10, (uint8_t *)lcdRegData17); + sendCmd(0, (uint8_t *)ShortRegData35); + sendCmd(10, (uint8_t *)lcdRegData18); + sendCmd(0, (uint8_t *)ShortRegData2); + sendCmd(10, (uint8_t *)lcdRegData19); + sendCmd(0, (uint8_t *)ShortRegData33); + sendCmd(15, (uint8_t *)lcdRegData20); + sendCmd(0, (uint8_t *)ShortRegData29); + sendCmd(15, (uint8_t *)lcdRegData21); + sendCmd(0, (uint8_t *)ShortRegData30); + sendCmd(10, (uint8_t *)lcdRegData22); + sendCmd(0, (uint8_t *)ShortRegData31); + sendCmd(15, (uint8_t *)lcdRegData23); + sendCmd(0, (uint8_t *)ShortRegData32); + sendCmd(15, (uint8_t *)lcdRegData24); + sendCmd(0, (uint8_t *)ShortRegData13); + sendCmd(0, (uint8_t *)ShortRegData47); + sendCmd(0, (uint8_t *)ShortRegData48); + sendCmd(0, (uint8_t *)ShortRegData49); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(3, (uint8_t *)lcdRegData25); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(16, (uint8_t *)lcdRegData3); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(16, (uint8_t *)lcdRegData4); + sendCmd(0, (uint8_t *)ShortRegData36); + Thread::sleep(120); + + /* Set Pixel color format to RGB565 */ + sendCmd(0, (uint8_t *)ShortRegData37); + /* Set Pixel color format to RGB888 */ + //sendCmd(0, (uint8_t *)ShortRegData38); + + #if defined MXGUI_ORIENTATION_HORIZONTAL + /* Send command to configure display in landscape orientation mode. + By default the orientation mode is portrait. */ + sendCmd(0, (uint8_t *)ShortRegData39); + sendCmd(4, (uint8_t *)lcdRegData27); + sendCmd(4, (uint8_t *)lcdRegData28); + #endif + + sendCmd(0, (uint8_t *)ShortRegData40); + sendCmd(0, (uint8_t *)ShortRegData41); + sendCmd(0, (uint8_t *)ShortRegData42); + sendCmd(0, (uint8_t *)ShortRegData43); + sendCmd(0, (uint8_t *)ShortRegData44); + sendCmd(0, (uint8_t *)ShortRegData1); + sendCmd(0, (uint8_t *)ShortRegData45); + /* End OTM8009A power up sequence */ + + // Disable command trasmission only in low power mode + DSI->CMCR &= ~(DSI_CMCR_GSW0TX | \ + DSI_CMCR_GSW1TX | \ + DSI_CMCR_GSW2TX | \ + DSI_CMCR_GSR0TX | \ + DSI_CMCR_GSR1TX | \ + DSI_CMCR_GSR2TX | \ + DSI_CMCR_GLWTX | \ + DSI_CMCR_DSW0TX | \ + DSI_CMCR_DSW1TX | \ + DSI_CMCR_DSR0TX | \ + DSI_CMCR_DLWTX | \ + DSI_CMCR_MRDPS); + + DSI->PCR &= ~(DSI_PCR_CRCRXE | DSI_PCR_ECCRXE | \ + DSI_PCR_BTAE | DSI_PCR_ETRXE | \ + DSI_PCR_ETTXE); + DSI->PCR |= DSI_PCR_BTAE; + + // Enable the LTDC + LTDC->GCR |= LTDC_GCR_LTDCEN; + + // Start the LTDC flow through the DSI wrapper (CR.LTDCEN = 1). + // In video mode, the data streaming starts as soon as the LTDC is enabled. + // In adapted command mode, the frame buffer update is launched as soon as the CR.LTDCEN bit is set. + DSI->CR |= DSI_CR_EN; + + // Update the display + DSI->WCR |= DSI_WCR_LTDCEN; + + setFont(droid11); + setTextColor(make_pair(Color(0xffff), Color(0x0000))); + clear(black); +} + +Color DisplayImpl::pixel_iterator::dummy; + +} //namespace mxgui + +#endif //_BOARD_STM32F469NI_STM32F469I_DISCO diff --git a/drivers/display_stm32f4discovery.h b/drivers/display_stm32f4discovery.h index bee1d5b21d3bfb73a439b58830a7f80d635ed3ec..2182bbdc4b985df074782ef1e6d00af88570d5c0 100644 --- a/drivers/display_stm32f4discovery.h +++ b/drivers/display_stm32f4discovery.h @@ -361,4 +361,340 @@ private: #endif //_BOARD_STM32F429ZI_STM32F4DISCOVERY +#ifdef _BOARD_STM32F469NI_STM32F469I_DISCO + +#include <config/mxgui_settings.h> +#include "display.h" +#include "point.h" +#include "color.h" +#include "font.h" +#include "image.h" +#include "iterator_direction.h" +#include "misc_inst.h" +#include "line.h" +#include <cstdio> +#include <cstring> +#include <algorithm> + +namespace mxgui { + +//This display is 16 bit per pixel, check that the color depth is properly +//configured +#ifndef MXGUI_COLOR_DEPTH_16_BIT +#error The OTM8009A driver requires a color depth of 16bit per pixel +#endif + +class DisplayImpl : public Display +{ +public: + /** + * \return an instance to this class (singleton) + */ + static DisplayImpl& instance(); + + /** + * Turn the display On after it has been turned Off. + * Display initial state is On. + */ + void doTurnOn() override; + + /** + * Turn the display Off. It can be later turned back On. + */ + void doTurnOff() override; + + /** + * Set display brightness. Depending on the underlying driver, + * may do nothing. + * \param brt from 0 to 100 + */ + void doSetBrightness(int brt) override; + + /** + * \return a pair with the display height and width + */ + std::pair<short int, short int> doGetSize() const override; + + /** + * Write text to the display. If text is too long it will be truncated + * \param p point where the upper left corner of the text will be printed + * \param text, text to print. + */ + void write(Point p, const char *text) override; + + /** + * Write part of text to the display + * \param p point of the upper left corner where the text will be drawn. + * Negative coordinates are allowed, as long as the clipped view has + * positive or zero coordinates + * \param a Upper left corner of clipping rectangle + * \param b Lower right corner of clipping rectangle + * \param text text to write + */ + void clippedWrite(Point p, Point a, Point b, const char *text) override; + + /** + * Clear the Display. The screen will be filled with the desired color + * \param color fill color + */ + void clear(Color color) override; + + /** + * Clear an area of the screen + * \param p1 upper left corner of area to clear + * \param p2 lower right corner of area to clear + * \param color fill color + */ + void clear(Point p1, Point p2, Color color) override; + + /** + * This backend does not require it, so it is a blank. + */ + void beginPixel() override; + + /** + * Draw a pixel with desired color. You have to call beginPixel() once + * before calling setPixel() + * \param p point where to draw pixel + * \param color pixel color + */ + void setPixel(Point p, Color color) override; + + /** + * Draw a line between point a and point b, with color c + * \param a first point + * \param b second point + * \param c line color + */ + void line(Point a, Point b, Color color) override; + + /** + * Draw an horizontal line on screen. + * Instead of line(), this member function takes an array of colors to be + * able to individually set pixel colors of a line. + * \param p starting point of the line + * \param colors an array of pixel colors whoase size must be b.x()-a.x()+1 + * \param length length of colors array. + * p.x()+length must be <= display.width() + */ + void scanLine(Point p, const Color *colors, unsigned short length) override; + + /** + * \return a buffer of length equal to this->getWidth() that can be used to + * render a scanline. + */ + Color *getScanLineBuffer() override; + + /** + * Draw the content of the last getScanLineBuffer() on an horizontal line + * on the screen. + * \param p starting point of the line + * \param length length of colors array. + * p.x()+length must be <= display.width() + */ + void scanLineBuffer(Point p, unsigned short length) override; + + /** + * Draw an image on the screen + * \param p point of the upper left corner where the image will be drawn + * \param i image to draw + */ + void drawImage(Point p, const ImageBase& img) override; + + /** + * Draw part of an image on the screen + * \param p point of the upper left corner where the image will be drawn. + * Negative coordinates are allowed, as long as the clipped view has + * positive or zero coordinates + * \param a Upper left corner of clipping rectangle + * \param b Lower right corner of clipping rectangle + * \param i Image to draw + */ + void clippedDrawImage(Point p, Point a, Point b, const ImageBase& img) override; + + /** + * Draw a rectangle (not filled) with the desired color + * \param a upper left corner of the rectangle + * \param b lower right corner of the rectangle + * \param c color of the line + */ + void drawRectangle(Point a, Point b, Color c) override; + + /** + * Make all changes done to the display since the last call to update() + * visible. This backend requires it. + */ + void update() override; + + /** + * Pixel iterator. A pixel iterator is an output iterator that allows to + * define a window on the display and write to its pixels. + */ + class pixel_iterator + { + public: + /** + * Default constructor, results in an invalid iterator. + * Note that since aIncr and sIncr are both zero all the writes will + * happens to the same memory location, but we need a safe + * /dev/null-like location where to write, which is dummy + */ + pixel_iterator() : ctr(0), endCtr(0), aIncr(0), sIncr(0), + dataPtr(&dummy) {} + + /** + * Set a pixel and move the pointer to the next one + * \param color color to set the current pixel + * \return a reference to this + */ + pixel_iterator& operator= (Color color) + { + *dataPtr=color; + + //This is to move to the adjacent pixel + dataPtr+=aIncr; + + //This is the step move to the next horizontal/vertical line + if(++ctr>=endCtr) + { + ctr=0; + dataPtr+=sIncr; + } + return *this; + } + + /** + * Compare two pixel_iterators for equality. + * They are equal if they point to the same location. + */ + bool operator== (const pixel_iterator& itr) + { + return this->dataPtr==itr.dataPtr; + } + + /** + * Compare two pixel_iterators for inequality. + * They different if they point to different locations. + */ + bool operator!= (const pixel_iterator& itr) + { + return this->dataPtr!=itr.dataPtr; + } + + /** + * \return a reference to this. + */ + pixel_iterator& operator* () { return *this; } + + /** + * \return a reference to this. Does not increment pixel pointer. + */ + pixel_iterator& operator++ () { return *this; } + + /** + * \return a reference to this. Does not increment pixel pointer. + */ + pixel_iterator& operator++ (int) { return *this; } + + /** + * Must be called if not all pixels of the required window are going + * to be written. + */ + void invalidate() {} + + private: + /** + * Constructor + * \param start Upper left corner of window + * \param end Lower right corner of window + * \param direction Iterator direction + * \param disp Display we're associated + */ + pixel_iterator(Point start, Point end, IteratorDirection direction, + DisplayImpl *disp) : ctr(0), dataPtr(disp->framebuffer1) + { + //Compute the increment in the adjacent direction (aIncr) and in the + //step direction (sIncr) depending on the direction + dataPtr+=start.y()*disp->getWidth()+start.x(); + if(direction==RD) + { + endCtr=end.x()+1-start.x(); + aIncr=1; + sIncr=disp->getWidth()-endCtr; + } else { + endCtr=end.y()+1-start.y(); + aIncr=disp->getWidth(); + sIncr=-aIncr*endCtr+1; + } + } + + unsigned short ctr; ///< Counter to decide when to step + unsigned short endCtr; ///< When ctr==endCtr apply a step + + short aIncr; ///< Adjacent increment + int sIncr; ///< Step increment + Color *dataPtr; ///< Pointer to framebuffer + + static Color dummy; ///< Invalid iterators write here + + friend class DisplayImpl; //Needs access to ctor + }; + + /** + * Specify a window on screen and return an object that allows to write + * its pixels. + * Note: a call to begin() will invalidate any previous iterator. + * \param p1 upper left corner of window + * \param p2 lower right corner (included) + * \param d increment direction + * \return a pixel iterator + */ + pixel_iterator begin(Point p1, Point p2, IteratorDirection d); + + /** + * \return an iterator which is one past the last pixel in the pixel + * specified by begin. Behaviour is undefined if called before calling + * begin() + */ + pixel_iterator end() const { return last; } + + /** + * Destructor + */ + ~DisplayImpl() override; + +private: + /** + * Constructor. + * Do not instantiate objects of this type directly from application code. + */ + DisplayImpl(); + + #if defined MXGUI_ORIENTATION_VERTICAL + static const short int width=480; + static const short int height=800; + #elif defined MXGUI_ORIENTATION_HORIZONTAL + static const short int width=800; + static const short int height=480; + #elif defined MXGUI_ORIENTATION_VERTICAL_MIRRORED || \ + defined MXGUI_ORIENTATION_HORIZONTAL_MIRRORED + #error unsupported orientation + #else + #error No orientation defined + #endif + + /** + * Pointer to the memory mapped display. + */ + Color * const framebuffer1; + Color *buffer; ///< For scanLineBuffer + pixel_iterator last; ///< Last iterator for end of iteration check + static const unsigned int bpp=sizeof(Color); ///< Bytes per pixel + static const int numPixels=width*height; ///< Number of pixels of the display +}; + +} //namespace mxgui + +#endif //_BOARD_STM32F469NI_STM32F469I_DISCO + #endif //DISPLAY_STM32F4DISCOVERY_H