Permalink
Browse files

Fixed:

 Bug when editing template file paths;
 A grid in the font preview dialog restored.

Added:
 Reordering bits;
 Scanning of the bands;
 Scaling by mouse wheel + Ctrl.
  • Loading branch information...
riuson committed Jan 9, 2013
2 parents b4efed4 + 697cc4f commit 4e8c626a9ac009c14f867b3b1a222cb530d6536c
Showing with 2,265 additions and 86 deletions.
  1. +112 −15 classes/convert/converterhelper.cpp
  2. +6 −0 classes/convert/converterhelper.h
  3. +19 −0 classes/data/historykeeper.cpp
  4. +19 −0 classes/data/historykeeper.h
  5. +19 −0 classes/data/historyrecord.cpp
  6. +19 −0 classes/data/historyrecord.h
  7. +29 −13 classes/parser.cpp
  8. +63 −0 classes/preview-models/reorderingitemdelegate.cpp
  9. +39 −0 classes/preview-models/reorderingitemdelegate.h
  10. +307 −0 classes/preview-models/reorderingpreviewmodel.cpp
  11. +75 −0 classes/preview-models/reorderingpreviewmodel.h
  12. +41 −0 classes/settings/presets/prepareoptions.cpp
  13. +6 −0 classes/settings/presets/prepareoptions.h
  14. +25 −11 classes/settings/presets/preset.cpp
  15. +3 −0 classes/settings/presets/preset.h
  16. +169 −0 classes/settings/presets/reorderingoptions.cpp
  17. +55 −0 classes/settings/presets/reorderingoptions.h
  18. +1 −0 controls/dialogfontpreview.cpp
  19. +10 −5 controls/setup/dialogoptions.cpp
  20. +7 −5 controls/setup/dialogoptions.h
  21. +15 −11 controls/setup/dialogpreview.cpp
  22. +18 −0 controls/setup/parts/setuptabprepare.cpp
  23. +2 −0 controls/setup/parts/setuptabprepare.h
  24. +24 −1 controls/setup/parts/setuptabprepare.ui
  25. +257 −0 controls/setup/parts/setuptabreordering.cpp
  26. +61 −0 controls/setup/parts/setuptabreordering.h
  27. +43 −0 controls/setup/parts/setuptabreordering.ui
  28. +6 −2 controls/setup/parts/setuptabtemplates.cpp
  29. +2 −2 controls/setup/parts/setuptabtemplates.h
  30. +44 −4 controls/widgetbitmapeditor.cpp
  31. +2 −0 controls/widgetbitmapeditor.h
  32. +12 −3 lcd-image-converter.pro
  33. BIN resources/demos/scanning_band.png
  34. +394 −0 resources/demos/scanning_band.svg
  35. +20 −0 resources/history.xml
  36. +83 −12 resources/lcd-image-converter-ru.ts
  37. +1 −0 resources/resources.qrc
  38. +4 −0 tests/maintest.cpp
  39. +27 −0 tests/parts/testprepareoptions.cpp
  40. +2 −0 tests/parts/testprepareoptions.h
  41. +6 −0 tests/parts/testpresets.cpp
  42. +181 −0 tests/parts/testreorderingoptions.cpp
  43. +31 −0 tests/parts/testreorderingoptions.h
  44. +6 −2 tests/test.pro
@@ -30,6 +30,7 @@
#include "preset.h"
#include "prepareoptions.h"
#include "matrixoptions.h"
#include "reorderingoptions.h"
#include "imageoptions.h"
#include "rlecompressor.h"
//-----------------------------------------------------------------------------
@@ -72,15 +73,51 @@ void ConverterHelper::pixelsData(Preset *preset, QImage *image, QVector<quint32>
ConverterHelper::makeGrayscale(im);
}

for (int y = 0; y < im.height(); y++)
if (preset->prepare()->bandScanning())
{
for (int x = 0; x < im.width(); x++)
const int bandSize = preset->prepare()->bandWidth();

int bandX = 0;

do
{
for (int y = 0; y < im.height(); y++)
{
for (int x = 0; x < bandSize; x++)
{
if (bandX + x < im.width())
{
// typedef QRgb
// An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
QRgb pixel = im.pixel(bandX + x, y);
quint32 value = pixel & 0x00ffffff;
data->append(value);
}
else
{
data->append(0x00000000);
}
}
}

bandX += bandSize;
} while (bandX < im.width());

// set new width
*width = bandX;
}
else
{
for (int y = 0; y < im.height(); y++)
{
// typedef QRgb
// An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
QRgb pixel = im.pixel(x, y);
quint32 value = pixel & 0x00ffffff;
data->append(value);
for (int x = 0; x < im.width(); x++)
{
// typedef QRgb
// An ARGB quadruplet on the format #AARRGGBB, equivalent to an unsigned int.
QRgb pixel = im.pixel(x, y);
quint32 value = pixel & 0x00ffffff;
data->append(value);
}
}
}
}
@@ -131,15 +168,40 @@ void ConverterHelper::packData(

if (preset->image()->splitToRows())
{
// process each row
for (int y = 0; y < inputHeight; y++)
if (preset->prepare()->bandScanning())
{
// start of row in inputData
int start = y * inputWidth;
// get row data packed
ConverterHelper::packDataRow(preset, inputData, start, inputWidth, outputData, &rowLength);
// get row blocks count
resultWidth = qMax(resultWidth, rowLength);
// non-standard row width

// bandsCount is divisible by bandSize (because of pixelsData() method)
int bandSize = preset->prepare()->bandWidth();
int bandsCount = inputWidth / bandSize;

// scanned rows count with bands
int rowsCount = inputHeight * bandsCount;

for (int row = 0; row < rowsCount; row++)
{
// start of row in inputData
int start = row * bandSize;
// get row data packed
ConverterHelper::packDataRow(preset, inputData, start, bandSize, outputData, &rowLength);
// get row blocks count
resultWidth = qMax(resultWidth, rowLength);
}
resultWidth *= bandsCount;
}
else
{
// process each standard row
for (int y = 0; y < inputHeight; y++)
{
// start of row in inputData
int start = y * inputWidth;
// get row data packed
ConverterHelper::packDataRow(preset, inputData, start, inputWidth, outputData, &rowLength);
// get row blocks count
resultWidth = qMax(resultWidth, rowLength);
}
}
}
else
@@ -153,6 +215,41 @@ void ConverterHelper::packData(
*outputWidth = resultWidth;
}
//-----------------------------------------------------------------------------
void ConverterHelper::reorder(
Preset *preset,
QVector<quint32> *inputData,
int inputWidth,
int inputHeight,
QVector<quint32> *outputData,
int *outputWidth,
int *outputHeight)
{
for (int i = 0; i < inputData->size(); i++)
{
quint32 value = inputData->at(i);
quint32 valueNew = 0;
for (int j = 0; j < preset->reordering()->operationsCount(); j++)
{
quint32 mask;
int shift;
bool left;
preset->reordering()->operation(j, &mask, &shift, &left);

if (left)
valueNew |= (value & mask) << shift;
else
valueNew |= (value & mask) >> shift;
}

if (preset->reordering()->operationsCount() == 0)
valueNew = value;

outputData->append(valueNew);
}
*outputWidth = inputWidth;
*outputHeight = inputHeight;
}
//-----------------------------------------------------------------------------
void ConverterHelper::compressData(
Preset *matrix,
QVector<quint32> *inputData,
@@ -47,6 +47,12 @@ class ConverterHelper
QVector<quint32> *outputData,
int *outputWidth,
int *outputHeight);
// bits reordering
static void reorder(
Preset *preset,
QVector<quint32> *inputData, int inputWidth, int inputHeight,
QVector<quint32> *outputData, int *outputWidth, int *outputHeight);

static void compressData(
Preset *matrix,
QVector<quint32> *inputData, int inputWidth, int inputHeight,
@@ -1,3 +1,22 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* 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 3 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.
*
* 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 "historykeeper.h"

#include <QStringList>
@@ -1,3 +1,22 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* 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 3 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/

#ifndef HISTORYKEEPER_H
#define HISTORYKEEPER_H
//-----------------------------------------------------------------------------
@@ -1,3 +1,22 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* 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 3 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.
*
* 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 "historyrecord.h"

#include <QStringList>
@@ -1,3 +1,22 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2012 riuson
* mailto: riuson@gmail.com
*
* 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 3 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.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/
*/

#ifndef HISTORYRECORD_H
#define HISTORYRECORD_H
//-----------------------------------------------------------------------------
@@ -221,24 +221,31 @@ void Parser::parseImagesTable(const QString &templateString,
ConverterHelper::prepareImage(this->mPreset, &image, &imagePrepared);

// conversion from image to strings
QVector<quint32> imageData;
int width, height;
ConverterHelper::pixelsData(this->mPreset, &imagePrepared, &imageData, &width, &height);
QVector<quint32> sourceData;
int sourceWidth, sourceHeight;
ConverterHelper::pixelsData(this->mPreset, &imagePrepared, &sourceData, &sourceWidth, &sourceHeight);

ConverterHelper::processPixels(this->mPreset, &imageData);
ConverterHelper::processPixels(this->mPreset, &sourceData);

QVector<quint32> imageDataPacked;
int width2, height2;
QVector<quint32> packedData;
int packedWidth, packedHeight;
ConverterHelper::packData(
this->mPreset,
&imageData, width, height,
&imageDataPacked, &width2, &height2);
&sourceData, sourceWidth, sourceHeight,
&packedData, &packedWidth, &packedHeight);

QVector<quint32> imageDataCompressed;
int width3, height3;
ConverterHelper::compressData(this->mPreset, &imageDataPacked, width2, height2, &imageDataCompressed, &width3, &height3);
QVector<quint32> reorderedData;
int reorderedWidth, reorderedHeight;
ConverterHelper::reorder(
this->mPreset,
&packedData, packedWidth, packedHeight,
&reorderedData, &reorderedWidth, &reorderedHeight);

QVector<quint32> compressedData;
int compressedWidth, compressedHeight;
ConverterHelper::compressData(this->mPreset, &reorderedData, reorderedWidth, reorderedHeight, &compressedData, &compressedWidth, &compressedHeight);

QString dataString = ConverterHelper::dataToString(this->mPreset, &imageDataCompressed, width3, height3, "0x");
QString dataString = ConverterHelper::dataToString(this->mPreset, &compressedData, compressedWidth, compressedHeight, "0x");
dataString.replace("\n", "\n" + tags["imageDataIndent"]);

// end of conversion
@@ -248,7 +255,7 @@ void Parser::parseImagesTable(const QString &templateString,

QString charCode = this->hexCode(key.at(0), encoding, useBom);

tags["blocksCount"] = QString("%1").arg(imageDataCompressed.size());
tags["blocksCount"] = QString("%1").arg(compressedData.size());
tags["imageData"] = dataString;
tags["charCode"] = charCode;
if (it.hasNext())
@@ -392,6 +399,15 @@ void Parser::addMatrixInfo(QMap<QString, QString> &tags) const
else
tags.insert("scanSub", "backward");

// bands
if (this->mPreset->prepare()->bandScanning())
tags.insert("bands", "yes");
else
tags.insert("bands", "no");
int bandWidth = this->mPreset->prepare()->bandWidth();
tags.insert("bandWidth", QString("%1").arg(bandWidth));


// inversion
if (this->mPreset->prepare()->inverse())
tags.insert("inverse", "yes");
@@ -0,0 +1,63 @@
/*
* LCD Image Converter. Converts images and fonts for embedded applications.
* Copyright (C) 2013 riuson
* mailto: riuson@gmail.com
*
* 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 3 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.
*
* 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 "reorderingitemdelegate.h"
//-----------------------------------------------------------------------------
ReorderingItemDelegate::ReorderingItemDelegate(QObject *parent) :
QItemDelegate(parent)
{
this->mColor= QColor("gold");
}
//-----------------------------------------------------------------------------
void ReorderingItemDelegate::paint(QPainter *painter,
const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.isValid())
{
int rows = index.model()->rowCount();
QRect rect = option.rect;
int row = index.row();
if (row == 0)
{
//painter->setPen(this->mColorOdd);
QPen pen(QBrush(this->mColor), 3);
painter->setPen(pen);
painter->drawLine(rect.left(), rect.bottom() - 1, rect.right(), rect.bottom() - 1);
}
if (row == rows - 1)
{
QPen pen(QBrush(this->mColor), 3);
painter->setPen(pen);
painter->drawLine(rect.left(), rect.top() + 1, rect.right(), rect.top() + 1);
}
}
QItemDelegate::paint(painter, option, index);
}
//-----------------------------------------------------------------------------
QColor ReorderingItemDelegate::color() const
{
return this->mColor;
}
//-----------------------------------------------------------------------------
void ReorderingItemDelegate::setColor(const QColor &value)
{
this->mColor = value;
}
//-----------------------------------------------------------------------------
Oops, something went wrong.

0 comments on commit 4e8c626

Please sign in to comment.