]> git.saurik.com Git - wxWidgets.git/commitdiff
added resolution option to JPEG handler (patch #833234)
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 31 Oct 2003 15:58:58 +0000 (15:58 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 31 Oct 2003 15:58:58 +0000 (15:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/imagjpeg.h
src/common/imagjpeg.cpp

index a043a783f86385d97d754bc7db6c5839eff92207..633b9045649263941f435ed6be29802eb64970b0 100644 (file)
@@ -93,6 +93,7 @@ All (GUI):
 - bug in wxWindow::RemoveEventHandler() fixed (Yingjun Zhang)
 - make it possible to use wxRTTI macros with namespaces (Benjamin I. Williams)
 - wxColourDatabase API now uses objects instead of pointers
+- added resolution option to JPEG image handler (Jeff Burton)
 
 wxMSW:
 
index 70e9541d594400588f862460c2be2c08d1da3141..07a1095c1bea4e39d2e1e139b842d53ec8aaacac 100644 (file)
 
 #include "wx/image.h"
 
+// defines for wxImage::SetOption
+#define wxIMAGE_OPTION_RESOLUTION            wxString(_T("Resolution"))
+#define wxIMAGE_OPTION_RESOLUTIONUNIT        wxString(_T("ResolutionUnit"))
+
+enum
+{
+    wxIMAGE_RESOLUTION_INCHES = 1,
+    wxIMAGE_RESOLUTION_CM = 2
+};
+
 //-----------------------------------------------------------------------------
 // wxJPEGHandler
 //-----------------------------------------------------------------------------
index a35e1e57e587c06f780677ab3d8f8aa5d6efc3dd..7590cee41733d8362dd54e5a656d8f35642e9b92 100644 (file)
@@ -356,6 +356,21 @@ bool wxJPEGHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbo
     if (image->HasOption(wxT("quality")))
         jpeg_set_quality(&cinfo, image->GetOptionInt(wxT("quality")), TRUE);
 
+    // sets the resolution fields in the output file
+    if (image->HasOption(wxIMAGE_OPTION_RESOLUTION))
+    {
+        cinfo.X_density = 
+        cinfo.Y_density = image->GetOptionInt(wxIMAGE_OPTION_RESOLUTION);
+    }
+
+    // sets the resolution unit field in the output file
+    // wxIMAGE_RESOLUTION_INCHES for inches
+    // wxIMAGE_RESOLUTION_CM for centimeters
+    if (image->HasOption(wxIMAGE_OPTION_RESOLUTIONUNIT))
+    {
+        cinfo.density_unit = image->GetOptionInt(wxIMAGE_OPTION_RESOLUTIONUNIT);
+    }
+
     jpeg_start_compress(&cinfo, TRUE);
 
     stride = cinfo.image_width * 3;    /* JSAMPLEs per row in image_buffer */