2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-09-30 07:14:28 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <glib-object.h>
|
|
|
|
|
|
|
|
#include "libgimpmath/gimpmath.h"
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
|
|
|
#include "config/gimpcoreconfig.h"
|
|
|
|
|
|
|
|
#include "gimp.h"
|
|
|
|
#include "gimpimage.h"
|
|
|
|
#include "gimpitem.h"
|
|
|
|
#include "gimpitem-preview.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_item_get_preview_size (GimpViewable *viewable,
|
|
|
|
gint size,
|
|
|
|
gboolean is_popup,
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
gint *width,
|
|
|
|
gint *height)
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2003-09-30 07:14:28 +08:00
|
|
|
|
|
|
|
item = GIMP_ITEM (viewable);
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-09-30 07:14:28 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image && ! image->gimp->config->layer_previews && ! is_popup)
|
2003-09-30 07:14:28 +08:00
|
|
|
{
|
|
|
|
*width = size;
|
|
|
|
*height = size;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image && ! is_popup)
|
2003-09-30 07:14:28 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_viewable_calc_preview_size (image->width,
|
|
|
|
image->height,
|
2003-09-30 07:14:28 +08:00
|
|
|
size,
|
|
|
|
size,
|
|
|
|
dot_for_dot,
|
2006-03-29 01:08:36 +08:00
|
|
|
image->xresolution,
|
|
|
|
image->yresolution,
|
2003-09-30 07:14:28 +08:00
|
|
|
width,
|
|
|
|
height,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2003-11-17 21:34:38 +08:00
|
|
|
gimp_viewable_calc_preview_size (item->width,
|
2003-09-30 07:14:28 +08:00
|
|
|
item->height,
|
|
|
|
size,
|
|
|
|
size,
|
2003-11-17 21:34:38 +08:00
|
|
|
dot_for_dot, 1.0, 1.0,
|
2003-09-30 07:14:28 +08:00
|
|
|
width,
|
|
|
|
height,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
gimp_item_get_popup_size (GimpViewable *viewable,
|
|
|
|
gint width,
|
|
|
|
gint height,
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
gint *popup_width,
|
|
|
|
gint *popup_height)
|
|
|
|
{
|
|
|
|
GimpItem *item;
|
2006-03-29 01:08:36 +08:00
|
|
|
GimpImage *image;
|
2003-09-30 07:14:28 +08:00
|
|
|
|
|
|
|
item = GIMP_ITEM (viewable);
|
2006-03-29 01:08:36 +08:00
|
|
|
image = gimp_item_get_image (item);
|
2003-09-30 07:14:28 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (image && ! image->gimp->config->layer_previews)
|
2003-09-30 07:14:28 +08:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (item->width > width || item->height > height)
|
|
|
|
{
|
|
|
|
gboolean scaling_up;
|
|
|
|
|
2003-11-17 21:34:38 +08:00
|
|
|
gimp_viewable_calc_preview_size (item->width,
|
2003-09-30 07:14:28 +08:00
|
|
|
item->height,
|
2003-10-09 20:26:46 +08:00
|
|
|
width * 2,
|
|
|
|
height * 2,
|
2003-09-30 07:14:28 +08:00
|
|
|
dot_for_dot,
|
2006-03-29 01:08:36 +08:00
|
|
|
image ? image->xresolution : 1.0,
|
|
|
|
image ? image->yresolution : 1.0,
|
2003-09-30 07:14:28 +08:00
|
|
|
popup_width,
|
|
|
|
popup_height,
|
|
|
|
&scaling_up);
|
|
|
|
|
|
|
|
if (scaling_up)
|
|
|
|
{
|
|
|
|
*popup_width = item->width;
|
|
|
|
*popup_width = item->height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|