summaryrefslogtreecommitdiffstats
path: root/src/image.cpp
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2009-12-22 16:03:24 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2009-12-22 16:03:24 (GMT)
commite32567534d95ff3960fa4dcad7733c18e1b39bc5 (patch)
treeed7891ebf8c1dbed877ba72eecb07d5da29b4978 /src/image.cpp
parent6f2abee157d4310a8272ca0f748ce6b812ae7260 (diff)
downloadDoxygen-e32567534d95ff3960fa4dcad7733c18e1b39bc5.zip
Doxygen-e32567534d95ff3960fa4dcad7733c18e1b39bc5.tar.gz
Doxygen-e32567534d95ff3960fa4dcad7733c18e1b39bc5.tar.bz2
Release-1.6.1-20091222
Diffstat (limited to 'src/image.cpp')
-rw-r--r--src/image.cpp73
1 files changed, 64 insertions, 9 deletions
diff --git a/src/image.cpp b/src/image.cpp
index e290e1b..d4bff4f 100644
--- a/src/image.cpp
+++ b/src/image.cpp
@@ -18,8 +18,19 @@
#include "qtbc.h"
#include "image.h"
-#include "gifenc.h"
+//#include "gifenc.h"
#include <qfile.h>
+#include "lodepng.h"
+
+typedef unsigned char Byte;
+
+struct Color
+{
+ Byte red;
+ Byte green;
+ Byte blue;
+ Byte alpha;
+};
const int charSetWidth=80;
const int charHeight=12;
@@ -143,16 +154,17 @@ unsigned char fontRaw[charSetWidth*charHeight] = {
static Color palette[] =
{
- { 0xff, 0xff, 0xff },
- { 0x00, 0x00, 0x00 },
- { 0xff, 0xff, 0xc0 },
- { 0x9f, 0x9f, 0x60 },
- { 0x90, 0x00, 0x00 },
- { 0x00, 0x90, 0x00 },
- { 0x00, 0x00, 0x90 },
- { 0xc0, 0xc0, 0xc0 }
+ { 0xff, 0xff, 0xff, 0x00 },
+ { 0x00, 0x00, 0x00, 0xff },
+ { 0xff, 0xff, 0xc0, 0xff },
+ { 0x9f, 0x9f, 0x60, 0xff },
+ { 0x90, 0x00, 0x00, 0xff },
+ { 0x00, 0x90, 0x00, 0xff },
+ { 0x00, 0x00, 0x90, 0xff },
+ { 0xc0, 0xc0, 0xc0, 0xff }
};
+#if 0
static Color palette2[] =
{
{ 0xff, 0xff, 0xff },
@@ -172,6 +184,28 @@ static Color palette2[] =
{ 0x10, 0x10, 0x10 },
{ 0x00, 0x00, 0x00 }
};
+#endif
+
+// for alpha we use x^(1/1.3)
+static Color palette2[] =
+{
+ { 0x00, 0x00, 0x00, 0x00 },
+ { 0x00, 0x00, 0x00, 0x2e },
+ { 0x00, 0x00, 0x00, 0x48 },
+ { 0x00, 0x00, 0x00, 0x5d },
+ { 0x00, 0x00, 0x00, 0x6f },
+ { 0x00, 0x00, 0x00, 0x80 },
+ { 0x00, 0x00, 0x00, 0x8f },
+ { 0x00, 0x00, 0x00, 0x9e },
+ { 0x00, 0x00, 0x00, 0xac },
+ { 0x00, 0x00, 0x00, 0xb9 },
+ { 0x00, 0x00, 0x00, 0xc5 },
+ { 0x00, 0x00, 0x00, 0xd2 },
+ { 0x00, 0x00, 0x00, 0xdd },
+ { 0x00, 0x00, 0x00, 0xe9 },
+ { 0x00, 0x00, 0x00, 0xf4 },
+ { 0x00, 0x00, 0x00, 0xff }
+};
Image::Image(int w,int h)
{
@@ -321,6 +355,7 @@ void Image::fillRect(int x,int y,int lwidth,int lheight,uchar colIndex,uint mask
bool Image::save(const char *fileName,int mode)
{
+#if 0
GifEncoder gifenc(data,
mode==0 ? palette : palette2,
width,height,
@@ -336,5 +371,25 @@ bool Image::save(const char *fileName,int mode)
{
return FALSE;
}
+#endif
+ uchar* buffer;
+ size_t bufferSize;
+ LodePNG_Encoder encoder;
+ LodePNG_Encoder_init(&encoder);
+ int numCols = mode==0 ? 8 : 16;
+ Color *pPal = mode==0 ? palette : palette2;
+ int i;
+ for (i=0;i<numCols;i++,pPal++)
+ {
+ LodePNG_InfoColor_addPalette(&encoder.infoPng.color,
+ pPal->red,pPal->green,pPal->blue,pPal->alpha);
+ }
+ encoder.infoPng.color.colorType = 3;
+ encoder.infoRaw.color.colorType = 3;
+ LodePNG_encode(&encoder, &buffer, &bufferSize, data, width, height);
+ LodePNG_saveFile(buffer, bufferSize, fileName);
+ free(buffer);
+ LodePNG_Encoder_cleanup(&encoder);
+ return TRUE;
}