From 3eafdc861af37cfacda4fcbfa2f65222bea79c13 Mon Sep 17 00:00:00 2001 From: Alex Merry Date: Sat, 15 Feb 2014 17:47:15 +0000 Subject: [PATCH] Remove the xv image format plugin It appears to be some internal format of xview, although I cannot find any mention of such a thing on the internet. There does not appear to be any sort of mime type to associate with this file format, either. Therefore, I think it is reasonable to declare it obsolete. REVIEW: 115768 --- autotests/CMakeLists.txt | 2 - autotests/read/xv/bw.png | Bin 969 -> 0 bytes autotests/read/xv/bw.xv | Bin 1081 -> 0 bytes autotests/read/xv/rgb.png | Bin 1130 -> 0 bytes autotests/read/xv/rgb.xv | 6 - src/imageformats/CMakeLists.txt | 8 -- src/imageformats/xv.desktop | 7 - src/imageformats/xview.cpp | 242 -------------------------------- src/imageformats/xview.h | 42 ------ src/imageformats/xview.json | 4 - 10 files changed, 311 deletions(-) delete mode 100644 autotests/read/xv/bw.png delete mode 100644 autotests/read/xv/bw.xv delete mode 100644 autotests/read/xv/rgb.png delete mode 100644 autotests/read/xv/rgb.xv delete mode 100644 src/imageformats/xv.desktop delete mode 100644 src/imageformats/xview.cpp delete mode 100644 src/imageformats/xview.h delete mode 100644 src/imageformats/xview.json 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 5f8fc8dd763d27e2685e1f236c2b78999a3f7072..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 969 zcmWktL5SC75PfDsySTfaJOs)@L$^@c4j#fN{!6navW2q{UhEL!VJPY#h@dGQ6e>pX z9w8(XL5rk?85fQD(L2DPANTB${CXq$Fwb8M_MWhyzX4s)b~ zE^slIbfGI;%{5)=4tH};cY46XJko<+@G`ITqBp$FJH0tnbec1roaBTBGQbdoSV)F2 z6rmQHp$td3g=aV;5MdD+!6-yoR7Nox(H5Q29L@wSm_be!!3tSm2}-OaOIV6hE6q}t zquk1~oE50BimYH2s;nxjSdD6{&T0;~i&o4cC);6-Y_J6_){-r3MXR-DE8Ed-?b*%_ zbXZ4runS$*m0j#cw{>SXM}nHx%qFKO!H68G8eyUsB}W2=@l>PcaBG-EH+l|bhoB5& zBb+QjR;}xQ~mIBVCkc&wp@Md`{U#BleO8~hxdJT z_x6psGkdpx`PcSKAHRO<$is!v4!*Yf{(-f{?;f4re0=WJ%Nw%ii{-hMZO*RSE9H~+i2xNCXa^B>;3zI5i)?@w?2 j^uim*9vpqL{~n${JbC=YY~Rl5ORlXRn*I3B(X;;pZPvt) diff --git a/autotests/read/xv/bw.xv b/autotests/read/xv/bw.xv deleted file mode 100644 index b884b2e9aa6641a4be1498b9303923b7e406a2e0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1081 zcmd5)K?;K~5X?ER5X=iAQt;ZwvWFz47U|6w>}U2d`7t_=2bO=>$*+NaH1^9i7#-KOC%|{r*@VE@zs?alU){ d^ysN;=Fxw&zFFU1e*w1p>zP)5<=o%j*$0Jvhy(xt diff --git a/autotests/read/xv/rgb.png b/autotests/read/xv/rgb.png deleted file mode 100644 index d584013eadd0aedcff7f758393f0486e7b954c49..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1130 zcmWlZTZq?n5XFx-s0GQFEeOKEfk43|h%O7>SaF0<38z02c0odF8<|M0!N9L}82;k#$!`nB^rZtVat ze;s!}*qpbw*9~);z5Bhrp96ES@qtZinkOKD0|f#|Kn^M}zyfw~K>-!0Lkk9&z#LWx zAOzuvLINpBM^>YR5|pE=EeRnwp@={vL{3!1AQoaLE>e&Rsgo8N$b`(viUJfu;S@y) zN}+VhYTQu?l~YyQCWPUPVgi#eIa4u%S(u%6EoMcI{06{@1@s-*@sQFFD@fQD$eMrlG*G+ncr6tzUl zwW=K_#NdW9f{_@xQ5nNnjNQ0QVJfC>T4pd4GdC*>ScrvNlqD?1(k-hYV`Hz_p3S4f37jvJ$uQt6F)BU&X@-rPpMeWs}pZrs6} zdx4uCZ?9QLRvdm3n6+SC_o_|zzPa_E4Oq5u?a0LF%;Ybltw&dEzZ!bag)QFS8rpT? zX#dQW3vVnQ99_8l>Nkh(fBwGH$3Hl;=Wxf?cR$_s^?{EU{qVx_)vG2Bb@fh6T-y8H z_d^@h2kyGF|L&e`2e0pbwR2|b`sv}m|IUn#Ui|5NU)6Bm)$21gb@s!Rv-|&==^MYi z=H#<~zj&tO_ox1tUh?C~$(v)x%9nfZI5*aszI=A=wT`9F9sF!+-{pM|jkl&RPIO)C zIJ$q!*{Rnz?>{lUWN_E`(wF8vd?LnLZ=aj&TR1#>_?^+6olhTF_QWlZ%sc=7`k~ia zBfGm!|GTsE(nkY7zttKUx~*$+OpXm4TQI!nR8Pvjn‘Ъ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": [ ] -}