|
View:
New views
7 Messages
—
Rating Filter:
Alert me
|
|
|
Covarage of Pixbuf constructor using byte[] and does scaling-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 The following bundle adds the mentioned cunstroctor but duplicates most (actually only a single line is changed) of the code from the non-scaling version. Can it be added without code duplication, Martin maybe you have an idea since you introduced its coverage. Thanks in advance. - -- Sincerely, Serkan KABA -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAko+EtcACgkQRh6X64ivZaJiSACeMKPzlBJOvXHz7+wZoeXj6cji X6QAnRTMBWn4gFQ/qqVHNSE2gfVsQ2Cc =hZId -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scaling-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Actually attaching the bundle. - -- Sincerely, Serkan KABA Gentoo Developer -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAko+HKYACgkQRh6X64ivZaJH2ACdG55esL8kxgaLtKg2UDDRIPLe bhIAmwU1TiQiT5t1gmfYMlFnSUKvsv2s =D4Jr -----END PGP SIGNATURE----- # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: serkan@... # target_branch: ../mainline/ # testament_sha1: 8bb0e4d97e250c71d6f2e80129648c1054a36396 # timestamp: 2009-06-21 13:36:13 +0300 # base_revision_id: andrew@...-\ # a8yn061ibbtx05zv # # Begin patch === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.c' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-02-02 09:22:37 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-06-21 00:56:39 +0000 @@ -33,8 +33,8 @@ jbyteArray result; int size; int j, p; - - + + // convert parameter self self = (GdkPixbuf*) _self; @@ -44,17 +44,17 @@ * formula is in the GDK docs [and more to the point, in the source * code of gdk_pixbuf_new()] but, as finally implemented, we don't * need it since we're extracting the rows individually, thereby - * jettisoning the padding. + * jettisoning the padding. */ - + width = gdk_pixbuf_get_width(self); height = gdk_pixbuf_get_height(self); rowstride = gdk_pixbuf_get_rowstride(self); n_channels = gdk_pixbuf_get_n_channels(self); bits_per_sample = gdk_pixbuf_get_bits_per_sample(self); - + // length = ((height - 1) * rowstride) + (width * ((n_channels * bits_per_sample + 7) / 8)); - + if (bits_per_sample != 8) { bindings_java_throw(env, "This algorithm only supports 8 bits per channel"); /* @@ -64,14 +64,14 @@ */ return NULL; } - + /* * Now we can extract the image data, and return it. */ // call function data = gdk_pixbuf_get_pixels(self); - + /* * Now copy the bytes of each pixel out row by row. Most of the time @@ -80,20 +80,20 @@ * dangling last row. We orginally had this in Pixbuf.java, but this * turns out to be 20% faster under heavy load. */ - + size = width * n_channels; - + result = (*env)->NewByteArray(env, height * size); - + p = 0; - + for (j = 0; j < height; j++) { (*env)->SetByteArrayRegion(env, result, p, size, (jbyte*) data); - + data += rowstride; p += size; } - + // and finally return result; } @@ -145,3 +145,53 @@ return (jlong) result; } + +//FIXME: Duplicate code. +JNIEXPORT jlong JNICALL Java_org_gnome_gdk_GdkPixbufOverride_gdk_1pixbuf_1new_1from_1stream_1at_1scale +( + JNIEnv* env, + jclass cls, + jbyteArray _data, + jint _width, + jint _height, + jboolean _preserveAspectRatio +) +{ + GInputStream *input_stream; + gssize len; + void *data; + GdkPixbuf* result; + GError* error = NULL; + + // set up the length and input stream parameters. + len = (*env)->GetArrayLength(env, _data); + data = (*env)->GetByteArrayElements(env, _data, NULL); + + /* + * Jump through the necessary hoops to feed an array of bytes to the + * GdkPixbuf constructor + */ + + input_stream = g_memory_input_stream_new_from_data(data, len, NULL); + + result = gdk_pixbuf_new_from_stream_at_scale(input_stream, _width, _height, _preserveAspectRatio, NULL, &error); + + g_input_stream_close(input_stream, NULL, NULL); + g_object_unref(input_stream); + + // cleanup parameter data + (*env)->ReleaseByteArrayElements(env, _data, data, 0); + + // cleanup return value + if (result != NULL) { + bindings_java_memory_cleanup((GObject*)result, TRUE); + } + + // check for a GError + if (error) { + bindings_java_throw_gerror(env, error); + return 0L; + } + + return (jlong) result; +} === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.java' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-01-06 09:26:19 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-06-21 00:56:39 +0000 @@ -36,4 +36,19 @@ } private static native final long gdk_pixbuf_new_from_stream(byte[] data) throws GlibException; + + static final long createPixbufFromArrayAtScale(byte[] data, int width, int height, + boolean preserveAspectRatio) throws GlibException { + if (data == null) { + throw new IllegalArgumentException("byte array can't be null"); + } + + synchronized (lock) { + return gdk_pixbuf_new_from_stream_at_scale(data, width, height, preserveAspectRatio); + } + } + + private static native final long gdk_pixbuf_new_from_stream_at_scale(byte[] data, int width, + int height, boolean preserveAspectRatio) throws GlibException; + } === modified file 'src/bindings/org/gnome/gdk/Pixbuf.java' --- src/bindings/org/gnome/gdk/Pixbuf.java 2009-02-02 09:22:37 +0000 +++ src/bindings/org/gnome/gdk/Pixbuf.java 2009-06-21 00:58:05 +0000 @@ -29,6 +29,7 @@ * will facilitate.</i> * * @author Andrew Cowie + * @author Serkan Kaba * @since 4.0.0 */ public class Pixbuf extends org.gnome.glib.Object @@ -127,6 +128,32 @@ } /** + * Construct a new Pixbuf from in-memory data and scale it. See + * {@link #Pixbuf(byte[])} for info on in-memory data.<br> + * See {@link #Pixbuf(String, int, int, boolean)} for info on scaling. + * + * @since 4.0.12 + */ + public Pixbuf(byte[] data, int width, int height, boolean preserveAspectRatio) throws IOException { + super(checkPixbufFromArrayAtScale(data, width, height, preserveAspectRatio)); + } + + private static long checkPixbufFromArrayAtScale(byte[] data, int width, int height, + boolean preserveAspectRatio) throws IOException { + try { + return GdkPixbufOverride.createPixbufFromArrayAtScale(data, width, height, + preserveAspectRatio); + } catch (GlibException ge) { + /* + * FIXME this will need to be more specific when our GError + * handling is better! IOException is the usual in stream-ish + * cases, but is it really appropriate here? + */ + throw new IOException(ge.getMessage()); + } + } + + /** * Create an identical copy of this Pixbuf. * * <p> # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWdaj4UwAB0J/gGRwQAB5//// ////+r////pgDh97nfPvT76+u8zoAAUL7N32enll9u6fXfT3LWNaDIU2YptBJJGUym1NPRqngNI8 lPUzJppqek9RpqfpNCHqekNPUDJ6h6RhkhCYJ6npGpp6nqABkaaAAAAADQAAEqaSeFPSaTIZqDE0 HqNMgDQAAAAAAaBpoinojUaYIeiaaNDRkABoAAAAADQEUSTJlMVPwhPR6jVPCnk0I2p6NQzIgbUH qD1D01HqaACqJMgmgAI0JU/CnlP1NqU8npNqT9UzxUeo0aPSaNAGmZMF8wb0SJRKCgkmDBMREyfg 9H+XDt/754IJkDULEPibDQSqHoT/ECsVavI4ogcMY5AsWXOeDHsnIth+NUUyKNdjUJHp8iVKyhaM trLDcKCIJOprhVwaYJmULsGFIQEoLFCNIfCnOgnjs0KlGZeU4FqVAEBWEO7qlijdjhVizWGV/xcd e8IRlW9VNN5Wi344lPW4aUjsPrrLsM2FdV1RbTgqpTN7+8ImqERLhE/rud3iPOZDg7Se/20u8gU7 /MPcGgIYgCIiIhHHafAIbGzplF160ZUjKY4WNQaldGJPhBr4hT3tej2RNIhyESERDWmYR3TFizps wQQiwJFcXGIqJyzVjafLcoUGrgRlbFtPsYaywmPeZzlcBj4ihFnQDysWJDqFW4ylGXkMBKKLScsn zYI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vWL7mGynfrnB3vx5Lka ONFM6Iv9BjMLkpSvXDjLglmYsPhTKEa4jO+8mPiLoi1yEdBPumHxpF5dFIMusTTohqNb6IRcjTPk 7KI9OZzLgxUR4hIWY6EDEGB0KOjQpI9coxMt8ozlDh2s6SlHuLGYvY63C0WvRBtweRjDl+7jZvmz /CceQto1wbcVPlSCzCBvXoXULKdCgL42BhhigEUh6ONAZJnhYN2yJK92OQ+fZiIXpIKDvmyHWBv7 IoYhPlN0xA5dUaVuJdSxERCHB6gqSfdEHCfoMI9WSj+7KsBcS1zn4BgNrAqjoM8bnLcvqLuSKcKE hrUfCmA= ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scalingOn Sun, 2009-06-21 at 14:42 +0300, Serkan Kaba wrote:
> Actually attaching the bundle. Serkan and I chatted about this last night on IRC. Essentially my feedback to him was "yes, duplication is bad, but hacky attempts to avoid duplication are worse." So I'll certainly accept this patch. ++ I just looked at gdk_pixbuf_new_from_stream_at_scale() in devhelp, and noticed that it takes -1 for width and height. So maybe we can implement both Pixbuf(byte[]) and Pixbuf(byte[], int, int, boolean) using the same code path, but using GdkPixbufOverride.createPixbufFromArrayAtScale(data, -1, -1, false); for the original method? I looked at the code in GTK's gdk-pixbuf/gdk-pixbuf-io.c, however, and I'm not actually sure that's a good idea. The at scale code paths do considerable extra work that we'd want to avoid. But I thought I'd mention the possibility for you to think about. AfC Sydney ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scaling-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Here's a more debuggable *hack* Please review it. Thanks, - -- Sincerely, Serkan KABA -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAko/xy4ACgkQRh6X64ivZaJH+ACePrgVztX4a3XB92o3d8AO5Ywz tRMAnjx6+TOtCkkp14pDJ17Jqu1Try8x =LyGn -----END PGP SIGNATURE----- === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.c' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-06-21 00:56:39 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-06-22 17:59:08 +0000 @@ -98,55 +98,6 @@ return result; } - -JNIEXPORT jlong JNICALL -Java_org_gnome_gdk_GdkPixbufOverride_gdk_1pixbuf_1new_1from_1stream -( - JNIEnv* env, - jclass cls, - jbyteArray _data -) -{ - GInputStream *input_stream; - gssize len; - void *data; - GdkPixbuf* result; - GError* error = NULL; - - // set up the length and input stream parameters. - len = (*env)->GetArrayLength(env, _data); - data = (*env)->GetByteArrayElements(env, _data, NULL); - - /* - * Jump through the necessary hoops to feed an array of bytes to the - * GdkPixbuf constructor - */ - - input_stream = g_memory_input_stream_new_from_data(data, len, NULL); - - result = gdk_pixbuf_new_from_stream(input_stream, NULL, &error); - - g_input_stream_close(input_stream, NULL, NULL); - g_object_unref(input_stream); - - // cleanup parameter data - (*env)->ReleaseByteArrayElements(env, _data, data, 0); - - // cleanup return value - if (result != NULL) { - bindings_java_memory_cleanup((GObject*)result, TRUE); - } - - // check for a GError - if (error) { - bindings_java_throw_gerror(env, error); - return 0L; - } - - return (jlong) result; -} - -//FIXME: Duplicate code. JNIEXPORT jlong JNICALL Java_org_gnome_gdk_GdkPixbufOverride_gdk_1pixbuf_1new_1from_1stream_1at_1scale ( JNIEnv* env, @@ -154,7 +105,8 @@ jbyteArray _data, jint _width, jint _height, - jboolean _preserveAspectRatio + jboolean _preserveAspectRatio, + jboolean _scale ) { GInputStream *input_stream; @@ -173,8 +125,10 @@ */ input_stream = g_memory_input_stream_new_from_data(data, len, NULL); - - result = gdk_pixbuf_new_from_stream_at_scale(input_stream, _width, _height, _preserveAspectRatio, NULL, &error); + if(_scale) + result = gdk_pixbuf_new_from_stream_at_scale(input_stream, _width, _height, _preserveAspectRatio, NULL, &error); + else + result = gdk_pixbuf_new_from_stream(input_stream, NULL, &error); g_input_stream_close(input_stream, NULL, NULL); g_object_unref(input_stream); === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.java' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-06-21 00:56:39 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-06-22 17:59:55 +0000 @@ -25,30 +25,18 @@ private static native final byte[] gdk_pixbuf_get_pixels(long self); - static final long createPixbufFromArray(byte[] data) throws GlibException { - if (data == null) { - throw new IllegalArgumentException("byte array can't be null"); - } - - synchronized (lock) { - return gdk_pixbuf_new_from_stream(data); - } - } - - private static native final long gdk_pixbuf_new_from_stream(byte[] data) throws GlibException; - - static final long createPixbufFromArrayAtScale(byte[] data, int width, int height, - boolean preserveAspectRatio) throws GlibException { - if (data == null) { - throw new IllegalArgumentException("byte array can't be null"); - } - - synchronized (lock) { - return gdk_pixbuf_new_from_stream_at_scale(data, width, height, preserveAspectRatio); + static final long createPixbufFromArray(byte[] data, int width, int height, + boolean preserveAspectRatio, boolean scale) throws GlibException { + if (data == null) { + throw new IllegalArgumentException("byte array can't be null"); + } + + synchronized (lock) { + return gdk_pixbuf_new_from_stream_at_scale(data, width, height, preserveAspectRatio, scale); } } private static native final long gdk_pixbuf_new_from_stream_at_scale(byte[] data, int width, - int height, boolean preserveAspectRatio) throws GlibException; + int height, boolean preserveAspectRatio, boolean scale) throws GlibException; } === modified file 'src/bindings/org/gnome/gdk/Pixbuf.java' --- src/bindings/org/gnome/gdk/Pixbuf.java 2009-06-21 00:58:05 +0000 +++ src/bindings/org/gnome/gdk/Pixbuf.java 2009-06-22 17:59:39 +0000 @@ -116,7 +116,7 @@ private static long checkPixbufFromArray(byte[] data) throws IOException { try { - return GdkPixbufOverride.createPixbufFromArray(data); + return GdkPixbufOverride.createPixbufFromArray(data, 0, 0, true, false); } catch (GlibException ge) { /* * FIXME this will need to be more specific when our GError @@ -128,8 +128,9 @@ } /** - * Construct a new Pixbuf from in-memory data and scale it. See - * {@link #Pixbuf(byte[])} for info on in-memory data.<br> + * Construct a new Pixbuf from in-memory data and scale it. + * <p> + * See {@link #Pixbuf(byte[])} for info on in-memory data.<br> * See {@link #Pixbuf(String, int, int, boolean)} for info on scaling. * * @since 4.0.12 @@ -141,8 +142,8 @@ private static long checkPixbufFromArrayAtScale(byte[] data, int width, int height, boolean preserveAspectRatio) throws IOException { try { - return GdkPixbufOverride.createPixbufFromArrayAtScale(data, width, height, - preserveAspectRatio); + return GdkPixbufOverride.createPixbufFromArray(data, width, height, preserveAspectRatio, + true); } catch (GlibException ge) { /* * FIXME this will need to be more specific when our GError ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scalingOn Mon, 2009-06-22 at 21:02 +0300, Serkan Kaba wrote:
> + jboolean _scale That's the other thing I was going to suggest. :) Go for it! AfC Sydney ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scaling-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1 Thanks for the review. Here's the new bundle. - -- Sincerely, Serkan KABA -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkpATdYACgkQRh6X64ivZaIwSgCfZsW/QvOrvKxWZ2mtkJUb5SZL RCAAn3wor+DERQQPSMXX2PQlWhfiEjS3 =UvDF -----END PGP SIGNATURE----- # Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: serkan@... # target_branch: ../mainline/ # testament_sha1: e2d9bd3e98667f1837e89d6e39f3bd67d15ced68 # timestamp: 2009-06-23 06:35:51 +0300 # base_revision_id: andrew@...-\ # a8yn061ibbtx05zv # # Begin patch === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.c' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-02-02 09:22:37 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.c 2009-06-23 03:31:42 +0000 @@ -33,8 +33,8 @@ jbyteArray result; int size; int j, p; - - + + // convert parameter self self = (GdkPixbuf*) _self; @@ -44,17 +44,17 @@ * formula is in the GDK docs [and more to the point, in the source * code of gdk_pixbuf_new()] but, as finally implemented, we don't * need it since we're extracting the rows individually, thereby - * jettisoning the padding. + * jettisoning the padding. */ - + width = gdk_pixbuf_get_width(self); height = gdk_pixbuf_get_height(self); rowstride = gdk_pixbuf_get_rowstride(self); n_channels = gdk_pixbuf_get_n_channels(self); bits_per_sample = gdk_pixbuf_get_bits_per_sample(self); - + // length = ((height - 1) * rowstride) + (width * ((n_channels * bits_per_sample + 7) / 8)); - + if (bits_per_sample != 8) { bindings_java_throw(env, "This algorithm only supports 8 bits per channel"); /* @@ -64,14 +64,14 @@ */ return NULL; } - + /* * Now we can extract the image data, and return it. */ // call function data = gdk_pixbuf_get_pixels(self); - + /* * Now copy the bytes of each pixel out row by row. Most of the time @@ -80,31 +80,33 @@ * dangling last row. We orginally had this in Pixbuf.java, but this * turns out to be 20% faster under heavy load. */ - + size = width * n_channels; - + result = (*env)->NewByteArray(env, height * size); - + p = 0; - + for (j = 0; j < height; j++) { (*env)->SetByteArrayRegion(env, result, p, size, (jbyte*) data); - + data += rowstride; p += size; } - + // and finally return result; } - -JNIEXPORT jlong JNICALL -Java_org_gnome_gdk_GdkPixbufOverride_gdk_1pixbuf_1new_1from_1stream +JNIEXPORT jlong JNICALL Java_org_gnome_gdk_GdkPixbufOverride_gdk_1pixbuf_1new_1from_1stream ( JNIEnv* env, jclass cls, - jbyteArray _data + jbyteArray _data, + jint _width, + jint _height, + jboolean _preserveAspectRatio, + jboolean _scale ) { GInputStream *input_stream; @@ -123,8 +125,10 @@ */ input_stream = g_memory_input_stream_new_from_data(data, len, NULL); - - result = gdk_pixbuf_new_from_stream(input_stream, NULL, &error); + if(_scale) + result = gdk_pixbuf_new_from_stream_at_scale(input_stream, _width, _height, _preserveAspectRatio, NULL, &error); + else + result = gdk_pixbuf_new_from_stream(input_stream, NULL, &error); g_input_stream_close(input_stream, NULL, NULL); g_object_unref(input_stream); === modified file 'src/bindings/org/gnome/gdk/GdkPixbufOverride.java' --- src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-01-06 09:26:19 +0000 +++ src/bindings/org/gnome/gdk/GdkPixbufOverride.java 2009-06-23 03:31:42 +0000 @@ -25,15 +25,18 @@ private static native final byte[] gdk_pixbuf_get_pixels(long self); - static final long createPixbufFromArray(byte[] data) throws GlibException { + static final long createPixbufFromArray(byte[] data, int width, int height, + boolean preserveAspectRatio, boolean scale) throws GlibException { if (data == null) { throw new IllegalArgumentException("byte array can't be null"); } synchronized (lock) { - return gdk_pixbuf_new_from_stream(data); + return gdk_pixbuf_new_from_stream(data, width, height, preserveAspectRatio, scale); } } - private static native final long gdk_pixbuf_new_from_stream(byte[] data) throws GlibException; + private static native final long gdk_pixbuf_new_from_stream(byte[] data, int width, + int height, boolean preserveAspectRatio, boolean scale) throws GlibException; + } === modified file 'src/bindings/org/gnome/gdk/Pixbuf.java' --- src/bindings/org/gnome/gdk/Pixbuf.java 2009-02-02 09:22:37 +0000 +++ src/bindings/org/gnome/gdk/Pixbuf.java 2009-06-23 03:31:42 +0000 @@ -29,6 +29,7 @@ * will facilitate.</i> * * @author Andrew Cowie + * @author Serkan Kaba * @since 4.0.0 */ public class Pixbuf extends org.gnome.glib.Object @@ -115,7 +116,35 @@ private static long checkPixbufFromArray(byte[] data) throws IOException { try { - return GdkPixbufOverride.createPixbufFromArray(data); + // Parameters 2-4 have no meaning when we're not scaling + return GdkPixbufOverride.createPixbufFromArray(data, 0, 0, true, false); + } catch (GlibException ge) { + /* + * FIXME this will need to be more specific when our GError + * handling is better! IOException is the usual in stream-ish + * cases, but is it really appropriate here? + */ + throw new IOException(ge.getMessage()); + } + } + + /** + * Construct a new Pixbuf from in-memory data and scale it. + * <p> + * See {@link #Pixbuf(byte[])} for info on in-memory data.<br> + * See {@link #Pixbuf(String, int, int, boolean)} for info on scaling. + * + * @since 4.0.12 + */ + public Pixbuf(byte[] data, int width, int height, boolean preserveAspectRatio) throws IOException { + super(checkPixbufFromArrayAtScale(data, width, height, preserveAspectRatio)); + } + + private static long checkPixbufFromArrayAtScale(byte[] data, int width, int height, + boolean preserveAspectRatio) throws IOException { + try { + return GdkPixbufOverride.createPixbufFromArray(data, width, height, preserveAspectRatio, + true); } catch (GlibException ge) { /* * FIXME this will need to be more specific when our GError # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWZuY3S0ACwH/gGRwQAB5//// ////+r////pgEhzudvO3u4Pbur493clN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e+4T QCTispBQC5kQNJiSpSkxoQwc85tRh+AeNQk0gGxVOzuiYNoQuAlywdrS1oQElCAKtQO42iVGgEaW CUDlLQUKMRClhvwP8mQbSBwiyYEyACDnALRvBW0NDrhJIfVGU55hKYhYqnEZUcPEae+OY0dBerNo sCmYk5UsYiEB9zehxtMjbnVTzK+qvlWEc1ZNNWaAmtEDH0qpqKqWvlpGoYIcGG2y3jULAJg5muIH yZOaysHlaXkALwmQErL6h+befB5DGhuAa0doxxqpwL6fnKU5QQ5vvDM6hhyU7EamxTNy7FDiey4M YL4TGSSWT1gzSH28+9GxAsCrYtUD/1bmmvxKnjHgcNqLiUOnY/1WSPWMsrvjJcrCE3qXFAfWY4aN ihqmFFB8iNqn0UNqFh3P5RIB5y2xG0SaOa/kYR3FDoIWITcYGIHAYUJIVnIC75Afgvgy3ErTzzt6 V+NyNGwYDTj2lKgauO8JJDEGGmMfR/x6Gz0DJoMM5hKYQzmknAoVUb8moTQ2iUsnoqQxsCmCpdIB O3eoVR+eX9KOYDZ+JGQ/UXhpQOTOTYBmcyXuB6ZpfrJ3ccZspndeo3TwLc+z0/FwFvBL4WZAQQWs 0dsGxhwG4tPdK9Q0LliypYTuFoQpmIFwMdJA90moZjIGszBBLlQMw5zvEJpWMI8HfIDblHkGY4TU O6IBNKGbUgyATVySRdcgIQP0NCHBAcs76gMbALdCxw00HcCYsazpttsbGxutZ7FonIBBhgkAAuSB iFIlKdc7y0zzosOr3QVmXOpjey+6SFW1Q1tis5DKrioWIfvbQgICAxKugDq4+ZQ47ah2nu2TWy72 zBq3hugggT2EEwOsHyNwfz+SPJLhAAwI3jjL4Jh1QZRLWUodEmbMSSdgPaGpai4E1P5kItunP/nn yBYBmSO9wgrlQNJzMA6pyrYVRAeIPoLuSKcKEhNzG6Wg ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
|
|
Re: Covarage of Pixbuf constructor using byte[] and does scalingOn Tue, 2009-06-23 at 06:36 +0300, Serkan Kaba wrote:
> Thanks for the review. Here's the new bundle. Made a few cleanups, then merged to 'mainline'. AfC Sydney ------------------------------------------------------------------------------ Are you an open source citizen? Join us for the Open Source Bridge conference! Portland, OR, June 17-19. Two days of sessions, one day of unconference: $250. Need another reason to go? 24-hour hacker lounge. Register today! http://ad.doubleclick.net/clk;215844324;13503038;v?http://opensourcebridge.org _______________________________________________ java-gnome-hackers mailing list java-gnome-hackers@... https://lists.sourceforge.net/lists/listinfo/java-gnome-hackers |
| Free embeddable forum powered by Nabble | Forum Help |