/[classpath]/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c
ViewVC logotype

Diff of /classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by mark, Fri Jul 30 16:01:47 2004 UTC revision 1.12 by craig, Mon Aug 9 16:54:09 2004 UTC
# Line 312  JNIEXPORT void JNICALL Java_gnu_java_awt Line 312  JNIEXPORT void JNICALL Java_gnu_java_awt
312    gdk_flush ();    gdk_flush ();
313    gdk_threads_leave ();    gdk_threads_leave ();
314  }  }
315    
316    static void flip_pixbuf (GdkPixbuf *pixbuf,
317                             jboolean flip_x,
318                             jboolean flip_y,
319                             jint width,
320                             jint height)
321    {
322      gint src_rs;
323      guchar *src_pix;
324    
325      src_rs = gdk_pixbuf_get_rowstride (pixbuf);
326      src_pix = gdk_pixbuf_get_pixels (pixbuf);
327    
328      if (flip_x)
329        {
330          gint i, channels;
331          guchar buf[4];
332    
333          channels = gdk_pixbuf_get_has_alpha (pixbuf) ? 4 : 3;
334    
335          for (i = 0; i < height; i++)
336            {
337              guchar *left = src_pix + i * src_rs;
338              guchar *right = left + channels * (width - 1);
339              while (left < right)
340                {
341                  g_memmove (buf, left, channels);
342                  g_memmove (left, right, channels);
343                  g_memmove (right, buf, channels);
344                  left += channels;
345                  right -= channels;
346                }
347            }
348        }
349    
350      if (flip_y)
351        {
352          guchar *top = src_pix;
353          guchar *bottom = top + (height - 1) * src_rs;
354          gpointer buf = g_malloc (src_rs);
355          
356          while (top < bottom)
357            {
358              g_memmove (buf, top, src_rs);
359              g_memmove (top, bottom, src_rs);
360              g_memmove (bottom, buf, src_rs);
361              top += src_rs;
362              bottom -= src_rs;
363            }
364    
365          g_free (buf);
366        }
367    }
368        
369    JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphics_copyAndScalePixmap
370      (JNIEnv *env, jobject obj, jobject offscreen, jboolean flip_x, jboolean flip_y,
371       jint src_x, jint src_y, jint src_width, jint src_height,
372       jint dest_x, jint dest_y, jint dest_width, jint dest_height)
373    {
374      struct graphics *g1, *g2;
375      GdkPixbuf *buf_src, *buf_dest;
376    
377      g1 = (struct graphics *) NSA_GET_PTR (env, obj);
378      g2 = (struct graphics *) NSA_GET_PTR (env, offscreen);
379    
380      gdk_threads_enter ();
381    
382      buf_src = gdk_pixbuf_get_from_drawable (NULL,
383                                              g2->drawable,
384                                              g2->cm,
385                                              src_x,
386                                              src_y,
387                                              0,
388                                              0,
389                                              src_width,
390                                              src_height);
391    
392      buf_dest = gdk_pixbuf_scale_simple (buf_src,
393                                          dest_width,
394                                          dest_height,
395                                          GDK_INTERP_BILINEAR);
396    
397      if (flip_x || flip_y)
398        {
399          flip_pixbuf (buf_dest, flip_x, flip_y, dest_width, dest_height);
400        }
401    
402      gdk_pixbuf_render_to_drawable (buf_dest,
403                                     g1->drawable,
404                                     g1->gc,
405                                     0,
406                                     0,
407                                     dest_x,
408                                     dest_y,
409                                     dest_width,
410                                     dest_height,
411                                     GDK_RGB_DITHER_NORMAL,
412                                     0,
413                                     0);
414    
415      g_object_unref (G_OBJECT (buf_src));
416      g_object_unref (G_OBJECT (buf_dest));
417    
418      gdk_threads_leave ();
419    }
420    
421    
422    

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26