new function that swaps the vertical and horizontal axis for the saved

2007-08-24  Raphael Quinet  <raphael@gimp.org>

	* plug-ins/jpeg/jpeg-settings.c (jpeg_swap_original_settings): new
	function that swaps the vertical and horizontal axis for the saved
	subsampling parameters and quantization tables.

	* plug-ins/jpeg/jpeg-exif.c (jpeg_exif_rotate): swap the saved
	settings when the image is rotated.  Fixes bug #466593.

	* devel-docs/release-howto.txt: added note about having admin
	access to Bugzilla and to the news section on www.gimp.org.

svn path=/trunk/; revision=23370
This commit is contained in:
Raphael Quinet 2007-08-24 18:38:30 +00:00 committed by Raphaël Quinet
parent a2bf6db38a
commit 91d99d4d63
4 changed files with 112 additions and 15 deletions

View File

@ -1,3 +1,15 @@
2007-08-24 Raphaël Quinet <raphael@gimp.org>
* plug-ins/jpeg/jpeg-settings.c (jpeg_swap_original_settings): new
function that swaps the vertical and horizontal axis for the saved
subsampling parameters and quantization tables.
* plug-ins/jpeg/jpeg-exif.c (jpeg_exif_rotate): swap the saved
settings when the image is rotated. Fixes bug #466593.
* devel-docs/release-howto.txt: added note about having admin
access to Bugzilla and to the news section on www.gimp.org.
2007-08-24 Raphaël Quinet <raphael@gimp.org> 2007-08-24 Raphaël Quinet <raphael@gimp.org>
* tools/pdbgen/pdb/selection.pdb: fixed incorrect description of * tools/pdbgen/pdb/selection.pdb: fixed incorrect description of

View File

@ -70,7 +70,7 @@
( ) Check out or update the 'gimp-web' module and change ( ) Check out or update the 'gimp-web' module and change
downloads/index.htrw. Commit this change, the web server should downloads/index.htrw. Commit this change, the web server should
then update itself soon (usually less than half an hour). then update itself soon (usually less than an hour).
( ) Bump the version number in configure.in and commit this change. ( ) Bump the version number in configure.in and commit this change.

View File

@ -18,8 +18,8 @@
/* /*
* EXIF-handling code for the jpeg plugin. May eventually be better * EXIF-handling code for the jpeg plugin. May eventually be better
* to move this stuff into libgimpbase and make it available for * to move this stuff into libgimpbase or a new libgimpmetadata and
* other plugins. * make it available for other plugins.
*/ */
#include "config.h" #include "config.h"
@ -45,6 +45,7 @@
#include "gimpexif.h" #include "gimpexif.h"
#include "jpeg.h" #include "jpeg.h"
#include "jpeg-settings.h"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
@ -248,20 +249,24 @@ jpeg_exif_rotate (gint32 image_ID,
case 5: /* flipped diagonally around '\' */ case 5: /* flipped diagonally around '\' */
gimp_image_rotate (image_ID, GIMP_ROTATE_90); gimp_image_rotate (image_ID, GIMP_ROTATE_90);
jpeg_swap_original_settings (image_ID);
gimp_image_flip (image_ID, GIMP_ORIENTATION_HORIZONTAL); gimp_image_flip (image_ID, GIMP_ORIENTATION_HORIZONTAL);
break; break;
case 6: /* 90 CW */ case 6: /* 90 CW */
gimp_image_rotate (image_ID, GIMP_ROTATE_90); gimp_image_rotate (image_ID, GIMP_ROTATE_90);
jpeg_swap_original_settings (image_ID);
break; break;
case 7: /* flipped diagonally around '/' */ case 7: /* flipped diagonally around '/' */
gimp_image_rotate (image_ID, GIMP_ROTATE_90); gimp_image_rotate (image_ID, GIMP_ROTATE_90);
jpeg_swap_original_settings (image_ID);
gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL); gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL);
break; break;
case 8: /* 90 CCW */ case 8: /* 90 CCW */
gimp_image_rotate (image_ID, GIMP_ROTATE_270); gimp_image_rotate (image_ID, GIMP_ROTATE_270);
jpeg_swap_original_settings (image_ID);
break; break;
default: /* can't happen */ default: /* can't happen */

View File

@ -31,14 +31,15 @@
* Additional data following the quantization tables is currently * Additional data following the quantization tables is currently
* ignored and can be used for future extensions. * ignored and can be used for future extensions.
* *
* The parasite contains the original subsampling for each component * In order to improve the compatibility with future versions of the
* instead of saving only the subsampling type as used by the jpeg * plug-in that may support more subsampling types ("subsmp"), the
* plug-in ("subsmp") in order to improve the compatibility with * parasite contains the original subsampling for each component
* future versions of the plug-in that may support more subsampling * instead of saving only one byte containing the subsampling type as
* types. The same applies to the other settings: for example, up to * used by the jpeg plug-in. The same applies to the other settings:
* 4 quantization tables will be saved in the parasite even if the * for example, up to 4 quantization tables will be saved in the
* current code cannot restore more than 3 of them (4 tables may be * parasite even if the current code cannot restore more than 2 of
* needed by unusual JPEG color spaces such as JCS_CMYK or JCS_YCCK). * them (4 tables may be needed by unusual JPEG color spaces such as
* JCS_CMYK or JCS_YCCK).
*/ */
#include "config.h" #include "config.h"
@ -280,14 +281,13 @@ jpeg_restore_original_tables (gint32 image_ID,
if (src_size >= 4) if (src_size >= 4)
{ {
src = gimp_parasite_data (parasite); src = gimp_parasite_data (parasite);
src += 2; num_components = src[2];
num_components = *src++; num_tables = src[3];
num_tables = *src++;
if (src_size >= (4 + num_components * 2 + num_tables * 128) if (src_size >= (4 + num_components * 2 + num_tables * 128)
&& num_tables == num_quant_tables) && num_tables == num_quant_tables)
{ {
src += num_components * 2; src += 4 + num_components * 2;
quant_tables = g_new (guint *, num_tables); quant_tables = g_new (guint *, num_tables);
for (t = 0; t < num_tables; t++) for (t = 0; t < num_tables; t++)
@ -310,3 +310,83 @@ jpeg_restore_original_tables (gint32 image_ID,
} }
return NULL; return NULL;
} }
/**
* jpeg_swap_original_settings:
* @image_ID: the image that may contain original jpeg settings in a parasite.
*
* Swap the horizontal and vertical axis for the saved subsampling
* parameters and quantization tables. This should be done if the
* image has been rotated by +90 or -90 degrees or if it has been
* mirrored along its diagonal.
*/
void
jpeg_swap_original_settings (gint32 image_ID)
{
GimpParasite *parasite;
const guchar *src;
glong src_size;
gint num_components;
gint num_tables;
guchar *new_data;
guchar *dest;
gint t;
gint i;
gint j;
parasite = gimp_image_parasite_find (image_ID, "jpeg-settings");
if (parasite)
{
src_size = gimp_parasite_data_size (parasite);
if (src_size >= 4)
{
src = gimp_parasite_data (parasite);
num_components = src[2];
num_tables = src[3];
if (src_size >= (4 + num_components * 2 + num_tables * 128))
{
new_data = g_new (guchar, src_size);
dest = new_data;
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
*dest++ = *src++;
for (i = 0; i < num_components; i++)
{
dest[0] = src[1];
dest[1] = src[0];
dest += 2;
src += 2;
}
for (t = 0; t < num_tables; t++)
{
for (i = 0; i < 8; i++)
{
for (j = 0; j < 8; j++)
{
dest[i * 16 + j * 2] = src[j * 16 + i * 2];
dest[i * 16 + j * 2 + 1] = src[j * 16 + i * 2 + 1];
}
}
dest += 128;
src += 128;
if (src_size > (4 + num_components * 2 + num_tables * 128))
{
memcpy (dest, src, src_size - (4 + num_components * 2
+ num_tables * 128));
}
}
gimp_parasite_free (parasite);
parasite = gimp_parasite_new ("jpeg-settings",
GIMP_PARASITE_PERSISTENT,
src_size,
new_data);
g_free (new_data);
gimp_image_parasite_attach (image_ID, parasite);
}
}
gimp_parasite_free (parasite);
}
}