diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 0192636..bedc3ad 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -53,7 +53,6 @@ kimageformats_read_tests( rgb tga xcf - xv ) # Basic write tests @@ -70,5 +69,4 @@ kimageformats_write_tests( pic-lossless rgb-lossless tga # fixme: the alpha images appear not to be written properly - xv ) diff --git a/autotests/read/xv/bw.png b/autotests/read/xv/bw.png deleted file mode 100644 index 5f8fc8d..0000000 Binary files a/autotests/read/xv/bw.png and /dev/null differ diff --git a/autotests/read/xv/bw.xv b/autotests/read/xv/bw.xv deleted file mode 100644 index b884b2e..0000000 Binary files a/autotests/read/xv/bw.xv and /dev/null differ diff --git a/autotests/read/xv/rgb.png b/autotests/read/xv/rgb.png deleted file mode 100644 index d584013..0000000 Binary files a/autotests/read/xv/rgb.png and /dev/null differ diff --git a/autotests/read/xv/rgb.xv b/autotests/read/xv/rgb.xv deleted file mode 100644 index 60cdbf3..0000000 --- a/autotests/read/xv/rgb.xv +++ /dev/null @@ -1,6 +0,0 @@ -P7 332 -#XVVERSION: -#IMGINFO: -#END_OF_COMMENTS: -32 32 255 -џџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџлЛОннОžЛЖЖйюв~ž{ЛОКйОПпџџџџџџлWмМ~>vjn‘Ъq]Zšš•И];ŸџџџџџџлW}Мм?>>rf'KЪВ~z7vššЙ~?ŸџџџџџџџлЛПоўпПŸžЛ‹gkзћџџПЛппџпПпџџџџџџџџџџџџџџџџџГoћџџџџџџџџџџџџџџџџџџџџџџџџџџџџ{[пџџџџџџџџџџџџџџџџџџџџџџџџџџџџ~}~пџџџџџџџџџџџџџџџџџџџџџџџџџџџџКЎкџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЮЩЮџџџџџџџџџџџџџџџџџџџџџџџџџџџџџѕ№ёџџџџџџџџџџџџџџџџџџџџџџџџџџџџџвŠЭћџџџџџџџџџџџџџџџџџџџџџџџџџџџџЏЂЋћџџџџџџџџџџџџџџџџџџџџџџџџџџџџђэюћџџџџџџџџџџџџџџџџџџџџџџџџџџџџжvжџџџџџџџџџџџџџџџџџџџџџџџџџџџџџšyšџџџџџџџџџџџџџџџџџџџџџџџџџџџџџнинџџџџџџџџџџџџџџџџџџџџџџџџџџџџџЕjЖџџџџџџџџџџџџџџџџџџџџџџџџџџџџџoOпџџџџџџџџџџџџџџџџџџџџџџџџџџџџoNRЛџџџџџџџџџџџџџџџџџџџџџџџџџџџџВ”Кџџџџџџџџџџџџџџџџџџџџџџџџџџџџж••кџџџџџџџџџџџџџџџџџџџџџџџџџџџџŸ>>ŸџџџџџџџџџџџџџџџџџџџџџџџџџџџџП~~ПџџџџџџџџџџџџџџџџџџџџџџџџџџџџоИИоџџџџџџџџџџџџџџџџџџџџџџџџџџџџКqqКџџџџџџџџџџџџџџџџџџџџџџџџџџџџЗ++Зџџџџџџџџџџџџџџџџџџџџџџџџџџџџл““лџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџџ \ No newline at end of file diff --git a/src/imageformats/CMakeLists.txt b/src/imageformats/CMakeLists.txt index 242753e..7cafd18 100644 --- a/src/imageformats/CMakeLists.txt +++ b/src/imageformats/CMakeLists.txt @@ -125,11 +125,3 @@ target_link_libraries(kimg_xcf Qt5::Gui) install(TARGETS kimg_xcf DESTINATION ${QT_PLUGIN_INSTALL_DIR}/imageformats/) install(FILES xcf.desktop DESTINATION ${SERVICES_INSTALL_DIR}/qimageioplugins/) -################################## - -add_library(kimg_xview MODULE xview.cpp) -target_link_libraries(kimg_xview Qt5::Gui) - -install(TARGETS kimg_xview DESTINATION ${QT_PLUGIN_INSTALL_DIR}/imageformats/) -install(FILES xv.desktop DESTINATION ${SERVICES_INSTALL_DIR}/qimageioplugins/) - diff --git a/src/imageformats/xv.desktop b/src/imageformats/xv.desktop deleted file mode 100644 index 9fa4a7e..0000000 --- a/src/imageformats/xv.desktop +++ /dev/null @@ -1,7 +0,0 @@ -[Desktop Entry] -Type=Service -X-KDE-ServiceTypes=QImageIOPlugins -X-KDE-ImageFormat=xv -X-KDE-MimeType= -X-KDE-Read=true -X-KDE-Write=true diff --git a/src/imageformats/xview.cpp b/src/imageformats/xview.cpp deleted file mode 100644 index af8539a..0000000 --- a/src/imageformats/xview.cpp +++ /dev/null @@ -1,242 +0,0 @@ -/** -* QImageIO Routines to read/write XV images. -* copyright (c) 1998 Torben Weis -* copyright (c) 1999 Oliver Eiden -* -* This library is distributed under the conditions of the GNU LGPL. -*/ - -#include "xview.h" - -#include -#include -#include -#include - -#define BUFSIZE 1024 - -static const int b_255_3[] = {0, 85, 170, 255}, // index*255/3 - rg_255_7[] = {0, 36, 72, 109, 145, 182, 218, 255}; // index *255/7 - -XVHandler::XVHandler() -{ -} - -bool XVHandler::canRead() const -{ - if (canRead(device())) { - setFormat("xv"); - return true; - } - return false; -} - -bool XVHandler::read(QImage *retImage) -{ - int x = -1; - int y = -1; - int maxval = -1; - QIODevice *iodev = device(); - - char str[ BUFSIZE ]; - - // magic number must be "P7 332" - iodev->readLine(str, BUFSIZE); - if (strncmp(str, "P7 332", 6)) { - return false; - } - - // next line #XVVERSION - iodev->readLine(str, BUFSIZE); - if (strncmp(str, "#XVVERSION", 10)) { - return false; - } - - // now it gets interesting, #BUILTIN means we are out. - // if IMGINFO comes, we are happy! - iodev->readLine(str, BUFSIZE); - if (strncmp(str, "#IMGINFO:", 9)) { - return false; - } - - // after this an #END_OF_COMMENTS signals everything to be ok! - iodev->readLine(str, BUFSIZE); - if (strncmp(str, "#END_OF", 7)) { - return false; - } - - // now a last line with width, height, maxval which is - // supposed to be 255 - iodev->readLine(str, BUFSIZE); - sscanf(str, "%d %d %d", &x, &y, &maxval); - - if (maxval != 255) { - return false; - } - int blocksize = x * y; - if (x < 0 || y < 0 || blocksize < x || blocksize < y) { - return false; - } - - // now follows a binary block of x*y bytes. - char *block = (char *) malloc(blocksize); - if (!block) { - return false; - } - - if (iodev->read(block, blocksize) != blocksize) { - free(block); - return false; - } - - // Create the image - QImage image(x, y, QImage::Format_Indexed8); - int numColors; - numColors = qMin(maxval + 1, 0); - numColors = qMax(0, maxval + 1); - image.setColorCount(numColors); - - // how do the color handling? they are absolute 24bpp - // or at least can be calculated as such. - int r, g, b; - - for (int j = 0; j < 256; j++) { - r = rg_255_7[((j >> 5) & 0x07)]; - g = rg_255_7[((j >> 2) & 0x07)]; - b = b_255_3[((j >> 0) & 0x03)]; - image.setColor(j, qRgb(r, g, b)); - } - - for (int py = 0; py < y; py++) { - uchar *data = image.scanLine(py); - memcpy(data, block + py * x, x); - } - - *retImage = image; - - free(block); - return true; -} - -bool XVHandler::write(const QImage &image) -{ - QIODevice &f = *(device()); - - // Removed "f.open(...)" and "f.close()" (tanghus) - - int w = image.width(), h = image.height(); - - char str[ 1024 ]; - - // magic number must be "P7 332" - f.write("P7 332\n", 7); - - // next line #XVVERSION - f.write("#XVVERSION:\n", 12); - - // now it gets interesting, #BUILTIN means we are out. - // if IMGINFO comes, we are happy! - f.write("#IMGINFO:\n", 10); - - // after this an #END_OF_COMMENTS signals everything to be ok! - f.write("#END_OF_COMMENTS:\n", 18); - - // now a last line with width, height, maxval which is supposed to be 255 - sprintf(str, "%i %i 255\n", w, h); - f.write(str, strlen(str)); - - QImage tmpImage(image); - if (image.depth() == 1) { - tmpImage = image.convertToFormat(QImage::Format_Indexed8, Qt::AutoColor); - } - - uchar *buffer = new uchar[ w ]; - - for (int py = 0; py < h; py++) { - const uchar *data = tmpImage.scanLine(py); - for (int px = 0; px < w; px++) { - int r, g, b; - if (tmpImage.depth() == 32) { - const QRgb *data32 = (QRgb *) data; - r = qRed(*data32) >> 5; - g = qGreen(*data32) >> 5; - b = qBlue(*data32) >> 6; - data += sizeof(QRgb); - } else { - QRgb color = tmpImage.color(*data); - r = qRed(color) >> 5; - g = qGreen(color) >> 5; - b = qBlue(color) >> 6; - data++; - } - buffer[ px ] = (r << 5) | (g << 2) | b; - } - f.write((const char *)buffer, w); - } - delete[] buffer; - - return true; -} - -bool XVHandler::canRead(QIODevice *device) -{ - if (!device) { - qWarning("XVHandler::canRead() called with no device"); - return false; - } - - qint64 oldPos = device->pos(); - - char head[6]; - qint64 readBytes = device->read(head, sizeof(head)); - if (readBytes != sizeof(head)) { - if (device->isSequential()) { - while (readBytes > 0) { - device->ungetChar(head[readBytes-- - 1]); - } - } else { - device->seek(oldPos); - } - return false; - } - - if (device->isSequential()) { - while (readBytes > 0) { - device->ungetChar(head[readBytes-- - 1]); - } - } else { - device->seek(oldPos); - } - - return qstrncmp(head, "P7 332", 6) == 0; -} - -QImageIOPlugin::Capabilities XVPlugin::capabilities(QIODevice *device, const QByteArray &format) const -{ - if (format == "xv") { - return Capabilities(CanRead | CanWrite); - } - if (!format.isEmpty()) { - return 0; - } - if (!device->isOpen()) { - return 0; - } - - Capabilities cap; - if (device->isReadable() && XVHandler::canRead(device)) { - cap |= CanRead; - } - if (device->isWritable()) { - cap |= CanWrite; - } - return cap; -} - -QImageIOHandler *XVPlugin::create(QIODevice *device, const QByteArray &format) const -{ - QImageIOHandler *handler = new XVHandler; - handler->setDevice(device); - handler->setFormat(format); - return handler; -} diff --git a/src/imageformats/xview.h b/src/imageformats/xview.h deleted file mode 100644 index 3e394e1..0000000 --- a/src/imageformats/xview.h +++ /dev/null @@ -1,42 +0,0 @@ -/** -* QImageIO Routines to read/write XV images. -* copyright (c) 1998 Torben Weis -* copyright (c) 1999 Oliver Eiden -* -* This library is distributed under the conditions of the GNU LGPL. -* -* -* Changelog: -* 23.3.99 Oliver Eiden -* changed the mapping from 3-3-2 decoded pixels to 8-8-8 decoded true-color pixels -* now it uses the same mapping as xv, this leads to better visual results -* Patch merged in HEAD by Chris Spiegel -*/ -#ifndef KIMG_XVIEW_H -#define KIMG_XVIEW_H - -#include - -class XVHandler : public QImageIOHandler -{ -public: - XVHandler(); - - virtual bool canRead() const; - virtual bool read(QImage *image); - virtual bool write(const QImage &image); - - static bool canRead(QIODevice *device); -}; - -class XVPlugin : public QImageIOPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QImageIOHandlerFactoryInterface" FILE "xview.json") - -public: - virtual Capabilities capabilities(QIODevice *device, const QByteArray &format) const; - virtual QImageIOHandler *create(QIODevice *device, const QByteArray &format = QByteArray()) const; -}; - -#endif // KIMG_XVIEW_H diff --git a/src/imageformats/xview.json b/src/imageformats/xview.json deleted file mode 100644 index 117effb..0000000 --- a/src/imageformats/xview.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Keys": [ "xv" ], - "MimeTypes": [ ] -}