< prev index next >
src/windows/classes/sun/awt/shell/Win32ShellFolder2.java
Print this page
*** 926,936 ****
boolean useVGAColors);
// Note: useVGAColors is ignored on XP and later
// Return the bits from an HICON. This has a side effect of setting
// the imageHash variable for efficient caching / comparing.
! private static native int[] getIconBits(long hIcon, int iconSize);
// Dispose the HICON
private static native void disposeIcon(long hIcon);
static native int[] getStandardViewButton0(int iconIndex);
--- 926,936 ----
boolean useVGAColors);
// Note: useVGAColors is ignored on XP and later
// Return the bits from an HICON. This has a side effect of setting
// the imageHash variable for efficient caching / comparing.
! private static native int[] getIconBits(long hIcon);
// Dispose the HICON
private static native void disposeIcon(long hIcon);
static native int[] getStandardViewButton0(int iconIndex);
*** 941,957 ****
}
return pIShellIcon;
}
! private static Image makeIcon(long hIcon, boolean getLargeIcon) {
if (hIcon != 0L && hIcon != -1L) {
// Get the bits. This has the side effect of setting the imageHash value for this object.
! int size = getLargeIcon ? 32 : 16;
! int[] iconBits = getIconBits(hIcon, size);
if (iconBits != null) {
! BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, size, size, iconBits, 0, size);
return img;
}
}
return null;
--- 941,958 ----
}
return pIShellIcon;
}
! private static Image makeIcon(long hIcon) {
if (hIcon != 0L && hIcon != -1L) {
// Get the bits. This has the side effect of setting the imageHash value for this object.
! final int[] iconBits = getIconBits(hIcon);
! // icons are always square
! final int size = (int)Math.sqrt(iconBits.length);
if (iconBits != null) {
! final BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
img.setRGB(0, 0, size, size, iconBits, 0, size);
return img;
}
}
return null;
*** 984,994 ****
imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
}
newIcon = (Image) imageCache.get(Integer.valueOf(index));
if (newIcon == null) {
long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
! newIcon = makeIcon(hIcon, getLargeIcon);
disposeIcon(hIcon);
if (newIcon != null) {
imageCache.put(Integer.valueOf(index), newIcon);
}
}
--- 985,995 ----
imageCache = getLargeIcon ? largeSystemImages : smallSystemImages;
}
newIcon = (Image) imageCache.get(Integer.valueOf(index));
if (newIcon == null) {
long hIcon = getIcon(getAbsolutePath(), getLargeIcon);
! newIcon = makeIcon(hIcon);
disposeIcon(hIcon);
if (newIcon != null) {
imageCache.put(Integer.valueOf(index), newIcon);
}
}
*** 997,1007 ****
if (newIcon == null) {
// These are only cached per object
long hIcon = extractIcon(getParentIShellFolder(),
getRelativePIDL(), getLargeIcon);
! newIcon = makeIcon(hIcon, getLargeIcon);
disposeIcon(hIcon);
}
if (newIcon == null) {
newIcon = Win32ShellFolder2.super.getIcon(getLargeIcon);
--- 998,1008 ----
if (newIcon == null) {
// These are only cached per object
long hIcon = extractIcon(getParentIShellFolder(),
getRelativePIDL(), getLargeIcon);
! newIcon = makeIcon(hIcon);
disposeIcon(hIcon);
}
if (newIcon == null) {
newIcon = Win32ShellFolder2.super.getIcon(getLargeIcon);
*** 1021,1031 ****
/**
* Gets an icon from the Windows system icon list as an <code>Image</code>
*/
static Image getSystemIcon(SystemIcon iconType) {
long hIcon = getSystemIcon(iconType.getIconID());
! Image icon = makeIcon(hIcon, true);
disposeIcon(hIcon);
return icon;
}
/**
--- 1022,1032 ----
/**
* Gets an icon from the Windows system icon list as an <code>Image</code>
*/
static Image getSystemIcon(SystemIcon iconType) {
long hIcon = getSystemIcon(iconType.getIconID());
! Image icon = makeIcon(hIcon);
disposeIcon(hIcon);
return icon;
}
/**
*** 1042,1052 ****
useVGAColors = shellIconBPP.equals("4");
}
long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
if (hIcon != 0) {
! Image icon = makeIcon(hIcon, getLargeIcon);
disposeIcon(hIcon);
return icon;
}
return null;
}
--- 1043,1053 ----
useVGAColors = shellIconBPP.equals("4");
}
long hIcon = getIconResource("shell32.dll", iconID, size, size, useVGAColors);
if (hIcon != 0) {
! Image icon = makeIcon(hIcon);
disposeIcon(hIcon);
return icon;
}
return null;
}
< prev index next >