epdfview-0.1.8-swap-the-blue-and-red-channel.patch 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From d30496f52b85f82947bd07b9bd60f8482843ece8 Mon Sep 17 00:00:00 2001
  2. From: jordi <jordi@cb4bfb15-1111-0410-82e2-95233c8f1c7e>
  3. Date: Tue, 5 Jul 2011 09:23:38 +0000
  4. Subject: [PATCH 1/2] When using Poppler 0.17.0, I needed to swap the blue and
  5. red channels, otherwise the colors (other than black
  6. and white) looked wierd.
  7. git-svn-id: svn://svn.emma-soft.com/epdfview/trunk@367 cb4bfb15-1111-0410-82e2-95233c8f1c7e
  8. ---
  9. src/PDFDocument.cxx | 20 ++++++++++++++++++++
  10. 1 files changed, 20 insertions(+), 0 deletions(-)
  11. diff --git a/src/PDFDocument.cxx b/src/PDFDocument.cxx
  12. index df5d75f..63b3513 100644
  13. --- a/src/PDFDocument.cxx
  14. +++ b/src/PDFDocument.cxx
  15. @@ -20,6 +20,7 @@
  16. #include <time.h>
  17. #include <poppler.h>
  18. #include <unistd.h>
  19. +#include <algorithm>
  20. #include "epdfview.h"
  21. using namespace ePDFView;
  22. @@ -33,6 +34,24 @@ static PageLayout convertPageLayout (gint pageLayout);
  23. static PageMode convertPageMode (gint pageMode);
  24. static gchar *getAbsoluteFileName (const gchar *fileName);
  25. +namespace
  26. +{
  27. + void
  28. + convert_bgra_to_rgba (guint8 *data, int width, int height)
  29. + {
  30. + using std::swap;
  31. +
  32. + for (int y = 0; y < height; y++)
  33. + {
  34. + for (int x = 0; x < width; x++)
  35. + {
  36. + swap(data[0], data[2]);
  37. + data += 4;
  38. + }
  39. + }
  40. + }
  41. +}
  42. +
  43. ///
  44. /// @brief Constructs a new PDFDocument object.
  45. ///
  46. @@ -650,6 +669,7 @@ PDFDocument::renderPage (gint pageNum)
  47. poppler_page_render (page, context);
  48. cairo_destroy(context);
  49. cairo_surface_destroy (surface);
  50. + convert_bgra_to_rgba(renderedPage->getData (), width, height);
  51. #else // !HAVE_POPPLER_0_17_0
  52. // Create the pixbuf from the data and render to it.
  53. GdkPixbuf *pixbuf = gdk_pixbuf_new_from_data (renderedPage->getData (),
  54. --
  55. 1.7.7