[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#575324: exactimage: file format misdetection



tags 575324 + patch
thanks

On Wednesday, March 24, 2010 10:40:32 PM you wrote:
> Package: exactimage
> Version: 0.7.5-3
> Severity: minor
> 
> y.pbm is a perfectly valid PBM file:
> 
> $ edentify y.pbm
> TGA: 80, 10, 1, 52, 255, 65343, ÿ
> y.pbm: TARGA 255x65343 0 bit, 3 channels

The problem seems to be that the TARGA codec is added too early to the codec 
datastructure. I worked around that problem using different strategies to 
insert the codec. 

Kind regards,
	Sven
Description: Add missing includes for std::vector
Author: Sven Eckelmann <sven@narfation.org>

---
diff --git a/codecs/pdf.hh b/codecs/pdf.hh
index 6beec621f75e18d4438866d80c8c41a0fd382f8f..0bf3f553494c5ae0ffcd1fe7ea4b7c6dc71a1145 100644
--- a/codecs/pdf.hh
+++ b/codecs/pdf.hh
@@ -16,6 +16,8 @@
  * copyright holder ExactCODE GmbH Germany.
  */
 
+#include <vector>
+
 #include "Codecs.hh"
 
 struct PDFContext; // fwd
diff --git a/codecs/xpm.cc b/codecs/xpm.cc
index 7736e3e70e1000a181c4e018e8595ebaf42e7cfa..0bf04b2ae2980acca0a5f9feb22d14fca37f8543 100644
--- a/codecs/xpm.cc
+++ b/codecs/xpm.cc
@@ -19,6 +19,7 @@
 #include <iostream>
 #include <string>
 #include <sstream>
+#include <vector>
 
 #include "xpm.hh"
 
diff --git a/lib/Colorspace.cc b/lib/Colorspace.cc
index 13df3513c66461d33eafb1a1b406700ac9cd0baf..832d88e05921cb2d2369368db2ea4cb9b8d3f24a 100644
--- a/lib/Colorspace.cc
+++ b/lib/Colorspace.cc
@@ -19,6 +19,7 @@
 
 #include <iostream>
 #include <map>
+#include <vector>
 
 #include "Image.hh"
 #include "ImageIterator2.hh"
Description: Fix misidentification of PNM as TGA
 TARGA files have nearly no magic values that can be used to distinguish them
 from other files. Therefore, it is important to test the other file codec
 handlers before testing for TARGA.
Author: Sven Eckelmann <sven@narfation.org>

---
diff --git a/codecs/Codecs.cc b/codecs/Codecs.cc
index 803e3e2e8f92ee8118a2512529c718e848241984..054548ff61db2f7dc82d24a32f40d8f512cb2dfb 100644
--- a/codecs/Codecs.cc
+++ b/codecs/Codecs.cc
@@ -22,7 +22,7 @@
 #include <iostream>
 #include <fstream>
 
-std::vector<ImageCodec::loader_ref>* ImageCodec::loader = 0;
+std::list<ImageCodec::loader_ref>* ImageCodec::loader = 0;
 
 ImageCodec::ImageCodec ()
   : _image (0)
@@ -78,7 +78,7 @@ int ImageCodec::Read (std::istream* stream, Image& image,
 {
   std::transform (codec.begin(), codec.end(), codec.begin(), tolower);
   
-  std::vector<loader_ref>::iterator it;
+  std::list<loader_ref>::iterator it;
   if (loader)
   for (it = loader->begin(); it != loader->end(); ++it)
     {
@@ -116,7 +116,7 @@ bool ImageCodec::Write (std::ostream* stream, Image& image,
   std::transform (codec.begin(), codec.end(), codec.begin(), tolower);
   std::transform (ext.begin(), ext.end(), ext.begin(), tolower);
   
-  std::vector<loader_ref>::iterator it;
+  std::list<loader_ref>::iterator it;
   if (loader)
   for (it = loader->begin(); it != loader->end(); ++it)
     {
@@ -150,7 +150,7 @@ ImageCodec* ImageCodec::MultiWrite (std::ostream* stream,
   std::transform (codec.begin(), codec.end(), codec.begin(), tolower);
   std::transform (ext.begin(), ext.end(), ext.begin(), tolower);
   
-  std::vector<loader_ref>::iterator it;
+  std::list<loader_ref>::iterator it;
   if (loader)
   for (it = loader->begin(); it != loader->end(); ++it)
     {
@@ -222,14 +222,17 @@ bool ImageCodec::Write (std::string file, Image& image,
 }
 
 void ImageCodec::registerCodec (const char* _ext, ImageCodec* _loader,
-				bool _via_codec_only)
+				bool _via_codec_only, bool push_back)
 {
   static ImageCodec* last_loader = 0;
   if (!loader)
-    loader = new std::vector<loader_ref>;
+    loader = new std::list<loader_ref>;
   
   loader_ref ref = {_ext, _loader, _loader != last_loader, _via_codec_only};
-  loader->push_back(ref);
+  if (push_back)
+    loader->push_back(ref);
+  else
+    loader->push_front(ref);
   last_loader = _loader;
 }
 
@@ -241,7 +244,7 @@ void ImageCodec::unregisterCodec (ImageCodec* _loader)
   }
   
   // remove from array
-  std::vector<loader_ref>::iterator it;
+  std::list<loader_ref>::iterator it;
   for (it = loader->begin(); it != loader->end();)
     if (it->loader == _loader)
       it = loader->erase (it);
diff --git a/codecs/Codecs.hh b/codecs/Codecs.hh
index e30a6b681cf6acc58173d41be023ea72852cb3d6..08790a14be44e9dde8721c1057a96d0b43a85e9d 100644
--- a/codecs/Codecs.hh
+++ b/codecs/Codecs.hh
@@ -18,7 +18,7 @@
 /* The Image decoder and coder collection.
  *
  * The class itself has static methods to perform the de- and
- * encoding. These methods search thru a loader vector to match the
+ * encoding. These methods search thru a loader list to match the
  * file magick (on decoding) or the specified codec / file extension
  * on encoding.
  *
@@ -36,7 +36,7 @@
 
 #include <stdio.h>
 
-#include <vector>
+#include <list>
 #include <algorithm>
 #include <iosfwd>
 
@@ -111,11 +111,12 @@ protected:
     bool via_codec_only;
   };
   
-  static std::vector<loader_ref>* loader;
+  static std::list<loader_ref>* loader;
   
   static void registerCodec (const char* _ext,
 			     ImageCodec* _loader,
-			     bool _via_codec_only = false);
+			     bool _via_codec_only = false,
+			     bool push_back = false);
   static void unregisterCodec (ImageCodec* _loader);
   
   // freestanding instance, attached to an image
diff --git a/codecs/tga.hh b/codecs/tga.hh
index 9652176cd176de7ab2a3763d2d83a1e2c03e3235..2d5eb7d97e967718ba11923e2cc7a33d5d7c1dfc 100644
--- a/codecs/tga.hh
+++ b/codecs/tga.hh
@@ -21,11 +21,11 @@ class TGACodec : public ImageCodec {
 public:
   
   TGACodec () {
-    registerCodec ("tga", this);
-    registerCodec ("tpic", this);
-    registerCodec ("vda", this);
-    registerCodec ("icb", this);
-    registerCodec ("vst", this);
+    registerCodec ("tga", this, false, true);
+    registerCodec ("tpic", this, false, true);
+    registerCodec ("vda", this, false, true);
+    registerCodec ("icb", this, false, true);
+    registerCodec ("vst", this, false, true);
   };
   
   virtual std::string getID () { return "TARGA"; };

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: