Handling color group by block of 3.5 pixels

This commit is contained in:
Christophe Meneboeuf 2016-11-29 23:32:37 +01:00
parent 6ba2158fd1
commit 6b68e7bc84
4 changed files with 37 additions and 22 deletions

11
RgbToHiRes.vcxproj.user Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LocalDebuggerCommandArguments>-i D:\Chris.ARES\Dropbox\_Partages\_Macbook\Green.png</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerCommandArguments>-i D:\Chris.ARES\Dropbox\_Partages\_Macbook\Green.png</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

View File

@ -17,12 +17,10 @@ namespace RgbToHires {
BlockHr::BlockHr(const BlockPixel& source)
{
const auto group = getGroup(source);
const auto groups = getGroup(source);
//Init data, depending on the group
for (auto& byte : _data) {
//Hi bit depending on color group
group == GROUP_1 ? byte = 0x0 : byte = 0x80;
}
groups.first == GROUP_1 ? _data[0] = 0x0 : _data[0] = 0x80;
groups.second == GROUP_1 ? _data[1] = 0x0 : _data[1] = 0x80;
//Getting the bit pairs
//Left 7 bit group
_data[0] |= getDibit(source[0]);
@ -39,19 +37,30 @@ namespace RgbToHires {
}
BlockHr::eColorGroup BlockHr::getGroup(const BlockPixel& block) const
std::pair<BlockHr::eColorGroup, BlockHr::eColorGroup> BlockHr::getGroup(const BlockPixel& block) const
{
auto group = GROUP_1;
for (const auto& color : block) {
if (color == GREEN || color == VIOLET) {
std::pair<eColorGroup, eColorGroup> groups{ GROUP_1, GROUP_1 };
//1st block group, including the last semi-pixel
for (auto i = 0u; i < 4u; ++i) {
if (block[i] == GREEN || block[i] == VIOLET) {
break;
}
if (color == ORANGE || color == BLUE) {
group = GROUP_2;
else if (block[i] == ORANGE || block[i] == BLUE) {
groups.first = GROUP_2;
break;
}
}
return group;
//2nd block group, excluding the first semi-pixel
for (auto i = 4u; i < 7u; ++i) {
if (block[i] == GREEN || block[i] == VIOLET) {
break;
}
else if (block[i] == ORANGE || block[i] == BLUE) {
groups.second = GROUP_2;
break;
}
}
return groups;
}
@ -81,7 +90,7 @@ namespace RgbToHires {
{
auto pixel_src = source.getConstPixels(0u, 0u, WIDTH, HEIGHT);
for (auto& line : _blobHr) {
for (auto& line : _blob) {
for (auto& block : line) {
BlockPixel blockPxRgb;
for (auto& pxRgb : blockPxRgb) {

View File

@ -9,8 +9,7 @@
namespace RgbToHires {
using BlockPixel = std::array<Magick::PixelPacket, 7>;
using LinePixel = std::array<BlockPixel, 20>;
using BlockPixel = std::array<Magick::PixelPacket, 7u>;
class BlockHr
{
@ -27,7 +26,7 @@ namespace RgbToHires {
};
/// \brief Returns the color group of these two pixel blocks
/// Works on double blocks instead of single blocks
eColorGroup getGroup(const BlockPixel&) const;
std::pair<eColorGroup, eColorGroup> getGroup(const BlockPixel&) const;
/// \brief Returns the bit pait corresponding to the given color
uint8_t getDibit(const Magick::Color&) const;
@ -35,8 +34,7 @@ namespace RgbToHires {
};
using LineHr = std::array<BlockHr, 10>;
template<class T>
using Blob = std::array<T, 192>;
using Blob = std::array<LineHr, 192>;
class HiRes
{
@ -46,9 +44,7 @@ namespace RgbToHires {
private:
Blob<LinePixel> _blobPx; ///< A frame ordered buffer of pixels
Blob<LineHr> _blobHr; ///< A frame ordered buffer of hires data
Blob _blob; ///< A frame ordered buffer of hires data
};

View File

@ -36,7 +36,6 @@ int main( int argc, char *argv[] )
}
const auto imageRgb = Magick::Image{ filepath };
auto imageQuantized = ImageQuantized{ imageRgb };
imageQuantized.write("C:\\Users\\Chris.ARES\\Temp\\toto.png");
const auto imageHiRes = HiRes{ imageQuantized };
}