summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/Palm2QImage.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/opie-reader/Palm2QImage.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-reader/Palm2QImage.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/noncore/apps/opie-reader/Palm2QImage.cpp b/noncore/apps/opie-reader/Palm2QImage.cpp
index 9603877..bf5ece3 100644
--- a/noncore/apps/opie-reader/Palm2QImage.cpp
+++ b/noncore/apps/opie-reader/Palm2QImage.cpp
@@ -1,30 +1,31 @@
/* -*- mode: c; indent-tabs-mode: nil; -*- */
+#include "useqpe.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifndef WINDOWS
-#include <unistd.h> /* for link */
+#ifndef _WINDOWS
+#include <unistd.h> /* for link */
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <stdarg.h>
#include <qimage.h>
/***********************************************************************/
/***********************************************************************/
/***** *****/
/***** Code to decode the Palm image format to JPEG *****/
/***** *****/
/***********************************************************************/
/***********************************************************************/
#define READ_BIGENDIAN_SHORT(p) (((p)[0] << 8)|((p)[1]))
#define READ_BIGENDIAN_LONG(p) (((p)[0] << 24)|((p)[1] << 16)|((p)[2] << 8)|((p)[3]))
#define PALM_IS_COMPRESSED_FLAG 0x8000
#define PALM_HAS_COLORMAP_FLAG 0x4000
#define PALM_HAS_TRANSPARENCY_FLAG 0x2000
#define PALM_DIRECT_COLOR_FLAG 0x0400
#define PALM_4_BYTE_FIELD_FLAG 0x0200
@@ -181,53 +182,53 @@ QImage* Palm2QImage
imagedatastart = palmimage + 16;
} else if (bits_per_pixel == 8) {
colormap = Palm8BitColormap;
imagedatastart = palmimage + 16;
} else if (bits_per_pixel == 16 && (flags & PALM_DIRECT_COLOR_FLAG)) {
colormap = NULL;
palm_red_bits = palmimage[16];
palm_green_bits = palmimage[17];
palm_blue_bits = palmimage[18];
// qDebug("Bits:%d, %d, %d", palm_red_bits, palm_green_bits, palm_blue_bits);
if (palm_blue_bits > 8 || palm_green_bits > 8 || palm_red_bits > 8) {
// qDebug("Can't handle this format DirectColor image -- too wide in some color (%d:%d:%d)\n", palm_red_bits, palm_green_bits, palm_blue_bits);
return NULL;
}
if (bits_per_pixel > (8 * sizeof(unsigned long))) {
// qDebug ("Can't handle this format DirectColor image -- too many bits per pixel (%d)\n", bits_per_pixel);
return NULL;
}
imagedatastart = palmimage + 24;
} else {
// qDebug("Unknown bits-per-pixel of %d encountered.\n", bits_per_pixel);
return NULL;
}
-#ifdef WINDOWS
- QImage* qimage = new QImage(width, height, 32);
-#else
- QImage* qimage = new QImage(width, height, 16);
-#endif
+#ifndef USEQPE
+ QImage* qimage = new QImage(width, height, 32);
+#else
+ QImage* qimage = new QImage(width, height, 16);
+#endif
/* row by row, uncompress the Palm image and copy it to the JPEG buffer */
rowbuf = new unsigned char[bytes_per_row * width];
lastrow = new unsigned char[bytes_per_row * width];
for (i=0, palm_ptr = imagedatastart , x_ptr = imagedata; i < height; ++i) {
// qDebug("inval:%x palm_ptr:%x x_ptr:%x bpr:%x", inval, palm_ptr, x_ptr, bytes_per_row);
/* first, uncompress the Palm image */
if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_RLE)) {
for (j = 0; j < bytes_per_row; ) {
incount = *palm_ptr++;
inval = *palm_ptr++;
memset(rowbuf + j, inval, incount);
j += incount;
}
} else if ((flags & PALM_IS_COMPRESSED_FLAG) && (compression_type == PALM_COMPRESSION_SCANLINE)) {
for (j = 0; j < bytes_per_row; j += 8) {
incount = *palm_ptr++;
inval = ((bytes_per_row - j) < 8) ? (bytes_per_row - j) : 8;
for (inbit = 0; inbit < inval; inbit += 1) {
if (incount & (1 << (7 - inbit)))
rowbuf[j + inbit] = *palm_ptr++;
else