added resolution option to JPEG handler (patch #833234)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24374 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2003-10-31 15:58:58 +00:00
parent 150018aebb
commit 89d38f8c3a
3 changed files with 26 additions and 0 deletions

View 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 */