improve image and pixel_buffer
This commit is contained in:
parent
8f59ccfbf6
commit
7f4cc3f6d9
@ -14,8 +14,11 @@
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-Wall" />
|
||||
<Add option="-g" />
|
||||
<Add directory="../../include" />
|
||||
<Add directory="../../extrlib/mingw" />
|
||||
</Compiler>
|
||||
</Target>
|
||||
<Target title="Release">
|
||||
@ -26,8 +29,11 @@
|
||||
<Option compiler="gcc" />
|
||||
<Option createDefFile="1" />
|
||||
<Compiler>
|
||||
<Add option="-Wall" />
|
||||
<Add option="-O2" />
|
||||
<Add option="-std=c++11" />
|
||||
<Add option="-Wall" />
|
||||
<Add directory="../../include" />
|
||||
<Add directory="../../extrlib/mingw" />
|
||||
</Compiler>
|
||||
<Linker>
|
||||
<Add option="-s" />
|
||||
|
@ -1,159 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<ActiveTarget name="Debug" />
|
||||
<File name="..\..\source\gui\detail\window_layout.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5198" topLine="161" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\graphics.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="30961" topLine="1020" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\image.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="3714" topLine="168" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\tooltip.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4739" topLine="194" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\threads\pool.cpp" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5569" topLine="249" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\dragger.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1316" topLine="59" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\msgbox.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="48249" topLine="407" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\tabbar.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="37420" topLine="1435" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\listbox.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="67946" topLine="2580" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\place.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="49985" topLine="1908" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\toolbar.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2244" topLine="84" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\programming_interface.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5022" topLine="159" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\button.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="7080" topLine="291" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\charset.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="412" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\animation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1164" topLine="43" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\detail\window_manager.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="30124" topLine="1046" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\treebox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="15535" topLine="539" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\audio\detail\buffer_preparation.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1924" topLine="62" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\combox.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="16572" topLine="610" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\element.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="20890" topLine="542" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\textbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="11188" topLine="459" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\date_chooser.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="457" topLine="3" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\filesystem\fs_utility.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1562" topLine="57" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\menu.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="27717" topLine="1044" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\detail\native_window_interface.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="4901" topLine="171" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\filebox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="22934" topLine="871" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\audio\detail\audio_device.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6256" topLine="215" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\checkbox.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6998" topLine="275" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\detail\platform_spec_selector.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="587" topLine="2" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\gui\widgets\categorize.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="6160" topLine="196" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="..\..\source\paint\text_renderer.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="5894" topLine="205" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
@ -35,7 +35,7 @@ $(BIN): $(LINKOBJ)
|
||||
ranlib ../bin/$(BIN)
|
||||
|
||||
.cpp.o:
|
||||
$(GCC) -g -c $< -o $@ $(INCS) -std=c++0x -Wall
|
||||
$(GCC) -g -c $< -o $@ $(INCS) -std=c++11 -Wall
|
||||
|
||||
clean:
|
||||
rm -f $(LINKOBJ)
|
||||
|
@ -68,31 +68,35 @@
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>../bin/</OutDir>
|
||||
<IncludePath>..\..\include;..\..\extrlib;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\..\include;..\..\extrlib\vc2013;$(IncludePath)</IncludePath>
|
||||
<SourcePath>..\..\source;$(VC_SourcePath);</SourcePath>
|
||||
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
|
||||
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
|
||||
<LibraryPath>..\..\extrlib\vc2013;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>..\..\include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\..\include;..\..\extrlib\vc2013;$(IncludePath)</IncludePath>
|
||||
<SourcePath>..\..\source;$(VC_SourcePath);</SourcePath>
|
||||
<OutDir>../bin/</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
|
||||
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
|
||||
<LibraryPath>..\..\extrlib\vc2013;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>../bin/</OutDir>
|
||||
<IncludePath>..\..\include;$(IncludePath)</IncludePath>
|
||||
<SourcePath>..\..\source;$(VC_SourcePath);</SourcePath>
|
||||
<IncludePath>..\..\include;..\..\extrlib\vc2013;$(IncludePath)</IncludePath>
|
||||
<SourcePath>..\..\source;$(VC_SourcePath)</SourcePath>
|
||||
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
|
||||
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
|
||||
<LibraryPath>..\..\extrlib\vc2013;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>..\..\include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\..\include;..\..\extrlib\vc2013;$(IncludePath)</IncludePath>
|
||||
<SourcePath>..\..\source;$(VC_SourcePath);</SourcePath>
|
||||
<OutDir>../bin/</OutDir>
|
||||
<TargetName>$(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName)</TargetName>
|
||||
<IntDir>..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\</IntDir>
|
||||
<LibraryPath>..\..\extrlib\vc2013;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -70,14 +70,24 @@
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>../../include;$(IncludePath)</IncludePath>
|
||||
<IncludePath>../../include;../../extrlib/vc2015;$(IncludePath)</IncludePath>
|
||||
<OutDir>..\bin\vc2015\</OutDir>
|
||||
<TargetName>lib$(ProjectName)</TargetName>
|
||||
<LibraryPath>../../extrlib/vc2015;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>../../include;../../extrlib;$(IncludePath)</IncludePath>
|
||||
<IncludePath>../../include;../../extrlib/vc2015;$(IncludePath)</IncludePath>
|
||||
<OutDir>..\bin\vc2015\</OutDir>
|
||||
<TargetName>lib$(ProjectName)d</TargetName>
|
||||
<LibraryPath>../../extrlib/vc2015;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>../../include;../../extrlib/vc2015;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>../../extrlib/vc2015;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>../../include;../../extrlib/vc2015;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>../../extrlib/vc2015;$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
|
@ -78,13 +78,15 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
///////////////////
|
||||
//Support for PNG
|
||||
// Comment it to disable the feature of support for PNG.
|
||||
//#define NANA_ENABLE_PNG
|
||||
// Define the NANA_ENABLE_PNG to enable the support of PNG.
|
||||
//
|
||||
//#define NANA_ENABLE_PNG //!
|
||||
#if defined(NANA_ENABLE_PNG)
|
||||
//Comment it to use libpng from operating system.
|
||||
#define NANA_LIBPNG
|
||||
#define NANA_LIBPNG //Comment it to use libpng from operating system.
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif //NANA_CONFIG_HPP
|
||||
|
@ -28,6 +28,18 @@ namespace detail
|
||||
{
|
||||
namespace algorithms
|
||||
{
|
||||
///@brief Seek a pixel address by using offset bytes
|
||||
///@return the specified pixel address
|
||||
inline pixel_color_t * pixel_at(pixel_color_t * p, std::size_t bytes) //deprecated
|
||||
{
|
||||
return reinterpret_cast<pixel_color_t*>(reinterpret_cast<char*>(p) + bytes);
|
||||
}
|
||||
|
||||
inline const pixel_color_t * pixel_at(const pixel_color_t * p, std::size_t bytes)
|
||||
{
|
||||
return reinterpret_cast<const pixel_color_t*>(reinterpret_cast<const char*>(p) + bytes);
|
||||
}
|
||||
|
||||
class proximal_interoplation
|
||||
: public image_process::stretch_interface
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Pixel Buffer Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
@ -18,18 +18,6 @@
|
||||
|
||||
namespace nana{ namespace paint
|
||||
{
|
||||
///@brief Seek a pixel address by using offset bytes
|
||||
///@return the specified pixel address
|
||||
inline pixel_color_t * pixel_at(pixel_color_t * p, std::size_t bytes)
|
||||
{
|
||||
return reinterpret_cast<pixel_color_t*>(reinterpret_cast<char*>(p)+bytes);
|
||||
}
|
||||
|
||||
inline const pixel_color_t * pixel_at(const pixel_color_t * p, std::size_t bytes)
|
||||
{
|
||||
return reinterpret_cast<const pixel_color_t*>(reinterpret_cast<const char*>(p)+bytes);
|
||||
}
|
||||
|
||||
class pixel_buffer
|
||||
{
|
||||
struct pixel_buffer_storage;
|
||||
@ -65,6 +53,8 @@ namespace nana{ namespace paint
|
||||
pixel_color_t * raw_ptr(std::size_t row) const;
|
||||
pixel_color_t * operator[](std::size_t row) const;
|
||||
|
||||
void fill_row(std::size_t row, const unsigned char* buffer, std::size_t bytes, unsigned bits_per_pixel);
|
||||
|
||||
void put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative);
|
||||
|
||||
void line(const std::string& name);
|
||||
|
@ -13,7 +13,8 @@
|
||||
#ifndef NANA_PAINT_DETAIL_IMAGE_BMP_HPP
|
||||
#define NANA_PAINT_DETAIL_IMAGE_BMP_HPP
|
||||
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include "image_pixbuf.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace nana{ namespace paint
|
||||
@ -65,7 +66,7 @@ namespace nana{ namespace paint
|
||||
#endif
|
||||
|
||||
class image_bmp
|
||||
:public image::image_impl_interface
|
||||
:public basic_image_pixbuf
|
||||
{
|
||||
public:
|
||||
image_bmp(){}
|
||||
@ -340,35 +341,6 @@ namespace nana{ namespace paint
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool empty() const override
|
||||
{
|
||||
return pixbuf_.empty();
|
||||
}
|
||||
|
||||
void close() override
|
||||
{
|
||||
pixbuf_.close();
|
||||
}
|
||||
|
||||
nana::size size() const override
|
||||
{
|
||||
return pixbuf_.size();
|
||||
}
|
||||
|
||||
void paste(const nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override
|
||||
{
|
||||
if(graph && pixbuf_)
|
||||
pixbuf_.paste(src_r, graph.handle(), p_dst);
|
||||
}
|
||||
|
||||
void stretch(const nana::rectangle& src_r, graph_reference graph, const nana::rectangle& r) const override
|
||||
{
|
||||
if(graph && pixbuf_)
|
||||
pixbuf_.stretch(src_r, graph.handle(), r);
|
||||
}
|
||||
private:
|
||||
nana::paint::pixel_buffer pixbuf_;
|
||||
};//end class bmpfile
|
||||
}//end namespace detail
|
||||
}//end namespace paint
|
||||
|
63
source/paint/detail/image_pixbuf.hpp
Normal file
63
source/paint/detail/image_pixbuf.hpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Basic Image PixelBuffer Implementation
|
||||
* Nana C++ Library(http://www.nanapro.org)
|
||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
||||
*
|
||||
* Distributed under the Boost Software License, Version 1.0.
|
||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||
* http://www.boost.org/LICENSE_1_0.txt)
|
||||
*
|
||||
* @file: nana/paint/detail/image_pixbuf.hpp
|
||||
*/
|
||||
|
||||
#ifndef NANA_PAINT_DETAIL_IMAGE_PIXBUF_HPP
|
||||
#define NANA_PAINT_DETAIL_IMAGE_PIXBUF_HPP
|
||||
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace paint{ namespace detail{
|
||||
|
||||
class basic_image_pixbuf
|
||||
: public image::image_impl_interface
|
||||
{
|
||||
public:
|
||||
bool alpha_channel() const override
|
||||
{
|
||||
return pixbuf_.alpha_channel();
|
||||
}
|
||||
|
||||
bool empty() const override
|
||||
{
|
||||
return pixbuf_.empty();
|
||||
}
|
||||
|
||||
void close() override
|
||||
{
|
||||
pixbuf_.close();
|
||||
}
|
||||
|
||||
::nana::size size() const override
|
||||
{
|
||||
return pixbuf_.size();
|
||||
}
|
||||
|
||||
void paste(const ::nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override
|
||||
{
|
||||
pixbuf_.paste(src_r, graph.handle(), p_dst);
|
||||
}
|
||||
|
||||
void stretch(const ::nana::rectangle& src_r, graph_reference dst, const nana::rectangle& r) const override
|
||||
{
|
||||
pixbuf_.stretch(src_r, dst.handle(), r);
|
||||
}
|
||||
protected:
|
||||
pixel_buffer pixbuf_;
|
||||
};
|
||||
}//end namespace detail
|
||||
}//end namespace paint
|
||||
}//end namespace nana
|
||||
|
||||
#endif
|
@ -1,7 +1,7 @@
|
||||
#ifndef NANA_PAINT_DETAIL_IMAGE_PNG_HPP
|
||||
#define NANA_PAINT_DETAIL_IMAGE_PNG_HPP
|
||||
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include "image_pixbuf.hpp"
|
||||
|
||||
//Separate the libpng from the package that system provides.
|
||||
#if defined(NANA_LIBPNG)
|
||||
@ -11,14 +11,13 @@
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
|
||||
namespace nana
|
||||
{
|
||||
namespace paint{ namespace detail{
|
||||
|
||||
class image_png
|
||||
: public image::image_impl_interface
|
||||
: public basic_image_pixbuf
|
||||
{
|
||||
public:
|
||||
bool open(const nana::char_t* png_file) override
|
||||
@ -164,39 +163,6 @@ namespace nana
|
||||
throw std::logic_error("PNG is not supported for raw data buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool alpha_channel() const override
|
||||
{
|
||||
return pixbuf_.alpha_channel();
|
||||
}
|
||||
|
||||
virtual bool empty() const override
|
||||
{
|
||||
return pixbuf_.empty();
|
||||
}
|
||||
|
||||
virtual void close() override
|
||||
{
|
||||
pixbuf_.close();
|
||||
}
|
||||
|
||||
virtual nana::size size() const override
|
||||
{
|
||||
return pixbuf_.size();
|
||||
}
|
||||
|
||||
void paste(const nana::rectangle& src_r, graph_reference graph, const point& p_dst) const override
|
||||
{
|
||||
pixbuf_.paste(src_r, graph.handle(), p_dst);
|
||||
}
|
||||
|
||||
void stretch(const nana::rectangle& src_r, graph_reference dst, const nana::rectangle& r) const override
|
||||
{
|
||||
pixbuf_.stretch(src_r, dst.handle(), r);
|
||||
}
|
||||
private:
|
||||
nana::paint::pixel_buffer pixbuf_;
|
||||
|
||||
};
|
||||
}//end namespace detail
|
||||
}//end namespace paint
|
||||
|
@ -20,9 +20,12 @@
|
||||
|
||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||
#include <nana/paint/pixel_buffer.hpp>
|
||||
|
||||
|
||||
#if defined(NANA_ENABLE_PNG)
|
||||
#include "detail/image_png.hpp"
|
||||
#endif
|
||||
|
||||
#include "detail/image_bmp.hpp"
|
||||
#include "detail/image_ico.hpp"
|
||||
|
||||
@ -155,16 +158,17 @@ namespace paint
|
||||
|
||||
image::image_impl_interface::~image_impl_interface()
|
||||
{}
|
||||
|
||||
namespace detail
|
||||
/*
|
||||
namespace detail
|
||||
{
|
||||
int toupper(int c)
|
||||
int toupper(int c) //deprecated
|
||||
{
|
||||
return (('a' <= c && c <= 'z') ?
|
||||
c - ('a' - 'A')
|
||||
: c);
|
||||
}
|
||||
}//end namespace detail
|
||||
//*/
|
||||
|
||||
//class image
|
||||
image::image()
|
||||
@ -216,25 +220,48 @@ namespace paint
|
||||
|
||||
if(filename.size())
|
||||
{
|
||||
nana::string fn;
|
||||
std::transform(filename.cbegin(), filename.cend(), std::back_inserter(fn), detail::toupper);
|
||||
|
||||
if(filename.size() >= 4)
|
||||
auto dotpos = filename.find_last_of('.');
|
||||
if (dotpos != filename.npos)
|
||||
{
|
||||
nana::string suffix = fn.substr(fn.size() - 4);
|
||||
if(STR(".ICO") == suffix)
|
||||
auto type_str = ::nana::cistring(filename.substr(dotpos + 1).data());
|
||||
|
||||
do
|
||||
{
|
||||
if (STR("ICO") == type_str)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
helper = new detail::image_ico(true);
|
||||
helper = new detail::image_ico(true);
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (STR("PNG") == type_str)
|
||||
{
|
||||
#if defined(NANA_ENABLE_PNG)
|
||||
else if(STR(".PNG") == suffix)
|
||||
helper = new detail::image_png;
|
||||
helper = new detail::image_png;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (STR("JPG") == type_str || STR("JPEG") == type_str)
|
||||
{
|
||||
#if defined(NANA_ENABLE_JPEG)
|
||||
helper = new detail::image_jpeg;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
} while (false);
|
||||
|
||||
}
|
||||
|
||||
if(0 == helper)
|
||||
//Check for BMP
|
||||
if(!helper)
|
||||
{
|
||||
#if defined(NANA_UNICODE)
|
||||
std::ifstream ifs(std::string(nana::charset(filename)).c_str(), std::ios::binary);
|
||||
|
@ -611,6 +611,63 @@ namespace nana{ namespace paint
|
||||
return reinterpret_cast<pixel_color_t*>(reinterpret_cast<char*>(sp->raw_pixel_buffer) + sp->bytes_per_line * row);
|
||||
}
|
||||
|
||||
void pixel_buffer::fill_row(std::size_t row, const unsigned char* buffer, std::size_t bytes, unsigned bits_per_pixel)
|
||||
{
|
||||
auto sp = storage_.get();
|
||||
if (!sp)
|
||||
return;
|
||||
|
||||
auto row_ptr = sp->raw_pixel_buffer + sp->pixel_size.width * row;
|
||||
|
||||
//the number of pixels will be copied
|
||||
auto const px_count = (sp->pixel_size.width <= (bytes / (bits_per_pixel / 8)) ? sp->pixel_size.width : (bytes / (bits_per_pixel / 8)));
|
||||
if (32 == bits_per_pixel)
|
||||
{
|
||||
std::memcpy(row_ptr, buffer, px_count * 4);
|
||||
}
|
||||
else if (24 == bits_per_pixel)
|
||||
{
|
||||
for (auto p = row_ptr, end = row_ptr + px_count; p != end; ++p)
|
||||
{
|
||||
p->element.red = buffer[0];
|
||||
p->element.green = buffer[1];
|
||||
p->element.blue = buffer[2];
|
||||
|
||||
buffer += 3;
|
||||
}
|
||||
}
|
||||
else if (16 == bits_per_pixel)
|
||||
{
|
||||
unsigned char palette[32];
|
||||
for (std::size_t i = 0; i < 32; ++i)
|
||||
palette[i] = static_cast<unsigned char>(i * 255 / 31);
|
||||
|
||||
#if defined(NANA_X11)
|
||||
unsigned char palette_6bits[64];
|
||||
for (std::size_t i = 0; i < 64; ++i)
|
||||
palette_6bits[i] = static_cast<unsigned char>(i * 255 / 63);
|
||||
#endif
|
||||
|
||||
auto px = reinterpret_cast<const unsigned short*>(buffer);
|
||||
|
||||
for (auto p = row_ptr, end = row_ptr + px_count; p != end; ++p)
|
||||
{
|
||||
p->element.red = palette[(*px >> 11) & 0x1F];
|
||||
|
||||
//16-bits RGB format under X is 565, under Windows is 555
|
||||
#if defined(NANA_X11)
|
||||
p->element.green = palette_6bits[(*px >> 5) & 0x3F];
|
||||
p->element.blue = palette_[*px & 0x1F];
|
||||
#else
|
||||
p->element.green = palette[(*px >> 6) & 0x1F];
|
||||
p->element.blue = palette[(*px >> 1) & 0x1F];
|
||||
#endif
|
||||
++px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void pixel_buffer::put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative)
|
||||
{
|
||||
if(storage_)
|
||||
|
Loading…
x
Reference in New Issue
Block a user