~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimppreviewcache.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1999 Andy Thomas alt@gimp.org
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
40
40
 
41
41
static gint
42
42
preview_cache_compare (gconstpointer  a,
43
 
                       gconstpointer  b)
 
43
                       gconstpointer  b)
44
44
{
45
 
  TempBuf *buf1 = (TempBuf *) a;
46
 
  TempBuf *buf2 = (TempBuf *) b;
 
45
  const TempBuf *buf1 = a;
 
46
  const TempBuf *buf2 = b;
47
47
 
48
48
  if (buf1->width > buf2->width && buf1->height > buf2->height)
49
49
    return -1;
53
53
 
54
54
static void
55
55
preview_cache_find_exact (gpointer data,
56
 
                          gpointer udata)
 
56
                          gpointer udata)
57
57
{
58
 
  TempBuf        *buf     = (TempBuf *) data;
59
 
  PreviewNearest *nearest = (PreviewNearest *) udata;
 
58
  TempBuf        *buf     = data;
 
59
  PreviewNearest *nearest = udata;
60
60
 
61
61
  if (nearest->buf)
62
62
    return;
63
63
 
64
 
  if (buf->width  == nearest->width && buf->height == nearest->height)
 
64
  if (buf->width == nearest->width && buf->height == nearest->height)
65
65
    {
66
66
      nearest->buf = buf;
67
67
      return;
70
70
 
71
71
static void
72
72
preview_cache_find_biggest (gpointer data,
73
 
                            gpointer udata)
 
73
                            gpointer udata)
74
74
{
75
 
  TempBuf        *buf     = (TempBuf *) data;
76
 
  PreviewNearest *nearest = (PreviewNearest *) udata;
 
75
  TempBuf        *buf     = data;
 
76
  PreviewNearest *nearest = udata;
77
77
 
78
 
  if (buf->width  >= nearest->width && buf->height >= nearest->height)
 
78
  if (buf->width >= nearest->width && buf->height >= nearest->height)
79
79
    {
80
80
      /* Ok we could make the preview out of this one...
81
81
       * If we already have it are these bigger dimensions?
82
82
       */
83
83
      if (nearest->buf)
84
 
        {
85
 
          if (nearest->buf->width > buf->width &&
86
 
              nearest->buf->height > buf->height)
87
 
            return;
88
 
        }
 
84
        {
 
85
          if (nearest->buf->width > buf->width &&
 
86
              nearest->buf->height > buf->height)
 
87
            return;
 
88
        }
89
89
 
90
90
      nearest->buf = buf;
91
91
    }
104
104
  for (list = *plist; list; list = list->next)
105
105
    {
106
106
      if (!smallest)
107
 
        {
108
 
          smallest = list->data;
109
 
        }
 
107
        {
 
108
          smallest = list->data;
 
109
        }
110
110
      else
111
 
        {
112
 
          TempBuf *this = list->data;
 
111
        {
 
112
          TempBuf *this = list->data;
113
113
 
114
 
          if ((smallest->height * smallest->width) >
115
 
              (this->height * this->width))
116
 
            {
117
 
              smallest = this;
118
 
            }
119
 
        }
 
114
          if (smallest->height * smallest->width > this->height * this->width)
 
115
            {
 
116
              smallest = this;
 
117
            }
 
118
        }
120
119
    }
121
120
 
122
121
  if (smallest)
165
164
 
166
165
void
167
166
gimp_preview_cache_add (GSList  **plist,
168
 
                        TempBuf  *buf)
 
167
                        TempBuf  *buf)
169
168
{
170
169
#ifdef PREVIEW_CACHE_DEBUG
171
170
  g_print ("gimp_preview_cache_add: %d x %d\n", buf->width, buf->height);
182
181
 
183
182
TempBuf *
184
183
gimp_preview_cache_get (GSList **plist,
185
 
                        gint     width,
186
 
                        gint     height)
 
184
                        gint     width,
 
185
                        gint     height)
187
186
{
188
187
  PreviewNearest pn;
189
188
 
249
248
      dest_data = temp_buf_data (preview);
250
249
 
251
250
      for (loop1 = 0 ; loop1 < height ; loop1++)
252
 
        for (loop2 = 0 ; loop2 < width ; loop2++)
253
 
          {
254
 
            gint    i;
255
 
            guchar *src_pixel;
256
 
            guchar *dest_pixel;
257
 
 
258
 
            src_pixel = src_data +
259
 
              ((gint) (loop2 * x_ratio)) * preview->bytes +
260
 
              ((gint) (loop1 * y_ratio)) * pwidth * preview->bytes;
261
 
 
262
 
            dest_pixel = dest_data +
263
 
              (loop2 + loop1 * width) * preview->bytes;
264
 
 
265
 
            for (i = 0; i < preview->bytes; i++)
266
 
              *dest_pixel++ = *src_pixel++;
267
 
          }
 
251
        for (loop2 = 0 ; loop2 < width ; loop2++)
 
252
          {
 
253
            gint    i;
 
254
            guchar *src_pixel;
 
255
            guchar *dest_pixel;
 
256
 
 
257
            src_pixel = src_data +
 
258
              ((gint) (loop2 * x_ratio)) * preview->bytes +
 
259
              ((gint) (loop1 * y_ratio)) * pwidth * preview->bytes;
 
260
 
 
261
            dest_pixel = dest_data +
 
262
              (loop2 + loop1 * width) * preview->bytes;
 
263
 
 
264
            for (i = 0; i < preview->bytes; i++)
 
265
              *dest_pixel++ = *src_pixel++;
 
266
          }
268
267
 
269
268
      gimp_preview_cache_add (plist, preview);
270
269