author | hgs |
Mon, 04 Oct 2010 11:29:25 +0300 | |
changeset 78 | 71ad690e91f5 |
parent 26 | dc7c549001d5 |
permissions | -rw-r--r-- |
26
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
1 |
/******************************************************************************* |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. This program and the accompanying materials |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
5 |
* which accompanies this distribution, and is available at |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
7 |
* |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
8 |
* Contributors: |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
9 |
* Nokia Corporation - initial implementation |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
10 |
*******************************************************************************/ |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
11 |
|
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
12 |
package org.eclipse.swt.internal.extension; |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
13 |
|
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
14 |
import org.eclipse.swt.graphics.Device; |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
15 |
import org.eclipse.swt.graphics.Image; |
78 | 16 |
import org.eclipse.swt.graphics.Point; |
26
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
17 |
import org.eclipse.swt.graphics.Internal_GfxPackageSupport; |
78 | 18 |
import java.io.InputStream; |
26
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
19 |
|
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
20 |
public final class ImageUtil{ |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
21 |
|
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
22 |
public static Image createImageWithoutSecurityCheck(Device device, String filename) { |
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
23 |
return Internal_GfxPackageSupport.createImageWithoutSecurityCheck(device, filename); |
78 | 24 |
} |
25 |
||
26 |
/** |
|
27 |
* @deprecated Use createImageFromTheme(Device device, String name) instead. |
|
28 |
* @param device |
|
29 |
* @param id |
|
30 |
* @return |
|
31 |
*/ |
|
32 |
public static Image createImageFromTheme(Device device, int id) { |
|
33 |
return null; |
|
34 |
} |
|
35 |
||
36 |
/** |
|
37 |
* Creates an eSWT Image from a theme icon. |
|
38 |
* Example: |
|
39 |
* Image image = ImageUtil.createImageFromTheme(display, "qtg_fr_rocker_normal_c"); |
|
40 |
* @param device |
|
41 |
* @param name |
|
42 |
* @return |
|
43 |
*/ |
|
44 |
public static Image createImageFromTheme(Device device, String name) { |
|
45 |
Image res = null; |
|
46 |
int iconHandle = org.eclipse.swt.internal.qt.OS.HbIcon_new(name); |
|
47 |
org.eclipse.swt.internal.qt.graphics.Image cgImage = |
|
48 |
org.eclipse.swt.internal.qt.graphics.Image.createImageFromPixmap( |
|
49 |
org.eclipse.swt.internal.qt.OS.HbIcon_pixmap(iconHandle)); |
|
50 |
res = Internal_GfxPackageSupport.new_Image(device, cgImage); |
|
51 |
org.eclipse.swt.internal.qt.OS.HbIcon_delete(iconHandle); |
|
52 |
return res; |
|
53 |
} |
|
54 |
||
55 |
/** |
|
56 |
* Returns the bounds of an Image without creating an actual Image instance. |
|
57 |
* Useful if there's a need to check the bounds of large collection of images |
|
58 |
* to choose one that gets initialized. |
|
59 |
* |
|
60 |
* For bitmap files the function returns the size of the bitmap. For SVG |
|
61 |
* the default size of the image is returned. |
|
62 |
* |
|
63 |
* Note that contents of the file are loaded to memory even when using |
|
64 |
* this function. If you are going to load the image anyway, using this |
|
65 |
* function is not efficient. |
|
66 |
* |
|
67 |
* @param device The device to use when loading |
|
68 |
* @param filename Filename from where to read the image data from. File is loaded from the classpath, not from the file system. |
|
69 |
* @return Size of the image |
|
70 |
* @throws IOException if image cannot be loaded |
|
71 |
*/ |
|
72 |
public static Point getImageSize(Device device, String filename) { |
|
73 |
return Internal_GfxPackageSupport.getImageSize(device, filename); |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* Returns the bounds of an Image without creating an actual Image instance. |
|
78 |
* Useful if there's a need to check the bounds of large collection of images |
|
79 |
* to choose one that gets initialized. |
|
80 |
* |
|
81 |
* For bitmap files the function returns the size of the bitmap. For SVG |
|
82 |
* the default size of the image is returned. |
|
83 |
* |
|
84 |
* Note that contents of the file are loaded to memory even when using |
|
85 |
* this function. If you are going to load the image anyway, using this |
|
86 |
* function is not efficient. |
|
87 |
* |
|
88 |
* @param is The InputStream from where to read the image data from |
|
89 |
* @return Size of the image |
|
90 |
* @throws IOException if image cannot be loaded |
|
91 |
*/ |
|
92 |
public static Point getImageSize(InputStream stream) { |
|
93 |
return Internal_GfxPackageSupport.getImageSize(stream); |
|
94 |
} |
|
26
dc7c549001d5
Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff
changeset
|
95 |
} |