mirror of https://github.com/GNOME/gimp.git
app/base/Makefile.am added new file that holds code to create a preview
2007-07-17 Sven Neumann <sven@gimp.org> * app/base/Makefile.am * app/base/tile-manager-preview.[ch]: added new file that holds code to create a preview from a tile manager. * app/core/gimpbuffer.c * app/core/gimpimage-preview.c: use the new function instead of duplicating this code. svn path=/trunk/; revision=22948
This commit is contained in:
parent
cd7a6f3e6c
commit
b47a3e52e5
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2007-07-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/base/Makefile.am
|
||||
* app/base/tile-manager-preview.[ch]: added new file that holds code
|
||||
to create a preview from a tile manager.
|
||||
|
||||
* app/core/gimpbuffer.c
|
||||
* app/core/gimpimage-preview.c: use the new function instead of
|
||||
duplicating this code.
|
||||
|
||||
2007-07-17 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/paint-funcs/scale-funcs.c (scale_region_no_resample): use
|
||||
|
|
|
@ -47,9 +47,11 @@ libappbase_a_SOURCES = \
|
|||
tile-cache.h \
|
||||
tile-manager.c \
|
||||
tile-manager.h \
|
||||
tile-manager-private.h \
|
||||
tile-manager-crop.c \
|
||||
tile-manager-crop.h \
|
||||
tile-manager-preview.c \
|
||||
tile-manager-preview.h \
|
||||
tile-manager-private.h \
|
||||
tile-pyramid.c \
|
||||
tile-pyramid.h \
|
||||
tile-swap.c \
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* 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 <glib-object.h>
|
||||
|
||||
#include "base-types.h"
|
||||
|
||||
#include "paint-funcs/scale-funcs.h"
|
||||
|
||||
#include "pixel-region.h"
|
||||
#include "temp-buf.h"
|
||||
#include "tile-manager.h"
|
||||
#include "tile-manager-preview.h"
|
||||
|
||||
|
||||
TempBuf *
|
||||
tile_manager_get_preview (TileManager *tiles,
|
||||
gint width,
|
||||
gint height)
|
||||
{
|
||||
TempBuf *preview;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
gint subsample;
|
||||
|
||||
g_return_val_if_fail (tiles != NULL, NULL);
|
||||
g_return_val_if_fail (width > 0 && height > 0, NULL);
|
||||
|
||||
pixel_region_init (&srcPR, tiles,
|
||||
0, 0,
|
||||
tile_manager_width (tiles), tile_manager_height (tiles),
|
||||
FALSE);
|
||||
|
||||
preview = temp_buf_new (width, height, tile_manager_bpp (tiles), 0, 0, NULL);
|
||||
|
||||
pixel_region_init_temp_buf (&destPR, preview, 0, 0, width, height);
|
||||
|
||||
/* calculate 'acceptable' subsample */
|
||||
subsample = 1;
|
||||
|
||||
while ((width * (subsample + 1) * 2 < srcPR.w) &&
|
||||
(height * (subsample + 1) * 2 < srcPR.h))
|
||||
subsample += 1;
|
||||
|
||||
subsample_region (&srcPR, &destPR, subsample);
|
||||
|
||||
return preview;
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef __TILE_MANAGER_PREVIEW_H__
|
||||
#define __TILE_MANAGER_PREVIEW_H__
|
||||
|
||||
|
||||
TempBuf * tile_manager_get_preview (TileManager *tiles,
|
||||
gint width,
|
||||
gint height);
|
||||
|
||||
|
||||
#endif /* __TILE_MANAGER_PREVIEW_H__ */
|
|
@ -26,10 +26,10 @@
|
|||
|
||||
#include "base/pixel-region.h"
|
||||
#include "base/tile-manager.h"
|
||||
#include "base/tile-manager-preview.h"
|
||||
#include "base/temp-buf.h"
|
||||
|
||||
#include "paint-funcs/paint-funcs.h"
|
||||
#include "paint-funcs/scale-funcs.h"
|
||||
|
||||
#include "gimpbuffer.h"
|
||||
|
||||
|
@ -201,51 +201,8 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
|
|||
gint height)
|
||||
{
|
||||
GimpBuffer *buffer = GIMP_BUFFER (viewable);
|
||||
TempBuf *temp_buf;
|
||||
gint buffer_width;
|
||||
gint buffer_height;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
gint bytes;
|
||||
|
||||
buffer_width = tile_manager_width (buffer->tiles);
|
||||
buffer_height = tile_manager_height (buffer->tiles);
|
||||
|
||||
bytes = tile_manager_bpp (buffer->tiles);
|
||||
|
||||
pixel_region_init (&srcPR, buffer->tiles,
|
||||
0, 0,
|
||||
buffer_width,
|
||||
buffer_height,
|
||||
FALSE);
|
||||
|
||||
if (buffer_height > height || buffer_width > width)
|
||||
temp_buf = temp_buf_new (width, height, bytes, 0, 0, NULL);
|
||||
else
|
||||
temp_buf = temp_buf_new (buffer_width, buffer_height, bytes, 0, 0, NULL);
|
||||
|
||||
pixel_region_init_temp_buf (&destPR, temp_buf,
|
||||
0, 0, temp_buf->width, temp_buf->height);
|
||||
|
||||
if (buffer_height > height || buffer_width > width)
|
||||
{
|
||||
gint subsample;
|
||||
|
||||
/* calculate 'acceptable' subsample */
|
||||
subsample = 1;
|
||||
|
||||
while ((width * (subsample + 1) * 2 < buffer_width) &&
|
||||
(height * (subsample + 1) * 2 < buffer_height))
|
||||
subsample += 1;
|
||||
|
||||
subsample_region (&srcPR, &destPR, subsample);
|
||||
}
|
||||
else
|
||||
{
|
||||
copy_region (&srcPR, &destPR);
|
||||
}
|
||||
|
||||
return temp_buf;
|
||||
return tile_manager_get_preview (buffer->tiles, width, height);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
|
|
|
@ -22,11 +22,8 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "base/pixel-region.h"
|
||||
#include "base/temp-buf.h"
|
||||
#include "base/tile-manager.h"
|
||||
|
||||
#include "paint-funcs/scale-funcs.h"
|
||||
#include "base/tile-manager-preview.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-preview.h"
|
||||
|
@ -126,14 +123,9 @@ gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
{
|
||||
GimpImage *image = GIMP_IMAGE (viewable);
|
||||
TileManager *tiles;
|
||||
TempBuf *preview;
|
||||
PixelRegion srcPR;
|
||||
PixelRegion destPR;
|
||||
gdouble scale_x;
|
||||
gdouble scale_y;
|
||||
gint level;
|
||||
gint bytes;
|
||||
gint subsample;
|
||||
|
||||
scale_x = (gdouble) width / (gdouble) image->width;
|
||||
scale_y = (gdouble) height / (gdouble) image->height;
|
||||
|
@ -141,25 +133,5 @@ gimp_image_get_new_preview (GimpViewable *viewable,
|
|||
level = gimp_projection_get_level (image->projection, scale_x, scale_y);
|
||||
tiles = gimp_projection_get_tiles_at_level (image->projection, level);
|
||||
|
||||
pixel_region_init (&srcPR, tiles,
|
||||
0, 0,
|
||||
tile_manager_width (tiles), tile_manager_height (tiles),
|
||||
FALSE);
|
||||
|
||||
bytes = gimp_projection_get_bytes (image->projection);
|
||||
|
||||
preview = temp_buf_new (width, height, bytes, 0, 0, NULL);
|
||||
|
||||
pixel_region_init_temp_buf (&destPR, preview, 0, 0, width, height);
|
||||
|
||||
/* calculate 'acceptable' subsample */
|
||||
subsample = 1;
|
||||
|
||||
while ((width * (subsample + 1) * 2 < srcPR.w) &&
|
||||
(height * (subsample + 1) * 2 < srcPR.h))
|
||||
subsample += 1;
|
||||
|
||||
subsample_region (&srcPR, &destPR, subsample);
|
||||
|
||||
return preview;
|
||||
return tile_manager_get_preview (tiles, width, height);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue