Mercurial > projects > dwt-linux
comparison dwt/dnd/ImageTransfer.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | ce446666f5a2 |
children |
comparison
equal
deleted
inserted
replaced
257:cc1d3de0e80b | 259:c0d810de7093 |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2004 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
22 | 22 |
23 import dwt.dwthelper.utils; | 23 import dwt.dwthelper.utils; |
24 | 24 |
25 /** | 25 /** |
26 * The class <code>ImageTransfer</code> provides a platform specific mechanism | 26 * The class <code>ImageTransfer</code> provides a platform specific mechanism |
27 * for converting a Image represented as a java <code>ImageData</code> to a | 27 * for converting an Image represented as a java <code>ImageData</code> to a |
28 * platform specific representation of the data and vice versa. | 28 * platform specific representation of the data and vice versa. |
29 * See <code>Transfer</code> for additional information. | |
30 * | 29 * |
31 * <p>An example of a java <code>ImageData</code> is shown | 30 * <p>An example of a java <code>ImageData</code> is shown below:</p> |
32 * below:</p> | |
33 * | 31 * |
34 * <code><pre> | 32 * <code><pre> |
35 * Image image = new Image("C:\temp\img1.gif"); | 33 * Image image = new Image(display, "C:\temp\img1.gif"); |
36 * ImageData imgData = image.getImageData(); | 34 * ImageData imgData = image.getImageData(); |
37 * </code></pre> | 35 * </code></pre> |
36 * | |
37 * @see Transfer | |
38 * | |
39 * @since 3.4 | |
38 */ | 40 */ |
39 public class ImageTransfer : ByteArrayTransfer { | 41 public class ImageTransfer : ByteArrayTransfer { |
40 | 42 |
41 private static ImageTransfer _instance; | 43 private static ImageTransfer _instance; |
42 | 44 |
91 } | 93 } |
92 | 94 |
93 /** | 95 /** |
94 * This implementation of <code>javaToNative</code> converts an ImageData object represented | 96 * This implementation of <code>javaToNative</code> converts an ImageData object represented |
95 * by java <code>ImageData</code> to a platform specific representation. | 97 * by java <code>ImageData</code> to a platform specific representation. |
96 * For additional information see <code>Transfer#javaToNative</code>. | |
97 * | 98 * |
98 * @param object a java <code>ImageData</code> containing the ImageData to be | 99 * @param object a java <code>ImageData</code> containing the ImageData to be converted |
99 * converted | 100 * @param transferData an empty <code>TransferData</code> object that will |
100 * @param transferData an empty <code>TransferData</code> object; this | 101 * be filled in on return with the platform specific format of the data |
101 * object will be filled in on return with the platform specific format of the data | 102 * |
103 * @see Transfer#nativeToJava | |
102 */ | 104 */ |
103 public void javaToNative(Object object, TransferData transferData) { | 105 public void javaToNative(Object object, TransferData transferData) { |
104 if (!checkImage(object) || !isSupportedType(transferData)) { | 106 if (!checkImage(object) || !isSupportedType(transferData)) { |
105 DND.error(DND.ERROR_INVALID_DATA); | 107 DND.error(DND.ERROR_INVALID_DATA); |
106 } | 108 } |
142 transferData.format = 32; | 144 transferData.format = 32; |
143 } | 145 } |
144 | 146 |
145 /** | 147 /** |
146 * This implementation of <code>nativeToJava</code> converts a platform specific | 148 * This implementation of <code>nativeToJava</code> converts a platform specific |
147 * representation of an <code>ImageData</code> to java. | 149 * representation of an image to java <code>ImageData</code>. |
148 * For additional information see <code>Transfer#nativeToJava</code>. | 150 * |
149 * | 151 * @param transferData the platform specific representation of the data to be converted |
150 * @param transferData the platform specific representation of the data to be | 152 * @return a java <code>ImageData</code> of the image if the conversion was successful; |
151 * been converted | 153 * otherwise null |
152 * @return a java <code>ImageData</code> the imageData of the image if | 154 * |
153 * conversion was successful; otherwise null | 155 * @see Transfer#javaToNative |
154 */ | 156 */ |
155 public Object nativeToJava(TransferData transferData) { | 157 public Object nativeToJava(TransferData transferData) { |
156 ImageData imgData = null; | 158 ImageData imgData = null; |
157 if (transferData.length > 0) | 159 if (transferData.length > 0) |
158 { | 160 { |