本文整理汇总了Java中sun.awt.image.ImageRepresentation.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageRepresentation.getWidth方法的具体用法?Java ImageRepresentation.getWidth怎么用?Java ImageRepresentation.getWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.awt.image.ImageRepresentation
的用法示例。
在下文中一共展示了ImageRepresentation.getWidth方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: IconInfo
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
public IconInfo(Image image) {
this.image = image;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
this.width = ir.getWidth();
this.height = ir.getHeight();
} else {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
this.scaledWidth = width;
this.scaledHeight = height;
this.rawLength = width * height + 2;
}
示例2: IconInfo
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
public IconInfo(Image image) {
this.image = image;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
this.width = ir.getWidth();
this.height = ir.getHeight();
} else {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
this.scaledWidth = width;
this.scaledHeight = height;
this.rawLength = getScaledRawLength(width, height);
}
示例3: XIconInfo
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
XIconInfo(Image image) {
this.image = image;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
this.width = ir.getWidth();
this.height = ir.getHeight();
} else {
this.width = image.getWidth(null);
this.height = image.getHeight(null);
}
this.scaledWidth = width;
this.scaledHeight = height;
this.rawLength = width * height + 2;
}
示例4: imageToPlatformBytes
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
@Override
protected byte[] imageToPlatformBytes(Image image, long format)
throws IOException {
String mimeType = null;
if (format == CF_PNG) {
mimeType = "image/png";
} else if (format == CF_JFIF) {
mimeType = "image/jpeg";
}
if (mimeType != null) {
return imageToStandardBytes(image, mimeType);
}
int width = 0;
int height = 0;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
} else {
width = image.getWidth(null);
height = image.getHeight(null);
}
// Fix for 4919639.
// Some Windows native applications (e.g. clipbrd.exe) do not handle
// 32-bpp DIBs correctly.
// As a workaround we switched to 24-bpp DIBs.
// MSDN prescribes that the bitmap array for a 24-bpp should consist of
// 3-byte triplets representing blue, green and red components of a
// pixel respectively. Additionally each scan line must be padded with
// zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
// We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
// with non-default scanline stride and pass the resulting data buffer
// to the native code to fill the BITMAPINFO structure.
int mod = (width * 3) % 4;
int pad = mod > 0 ? 4 - mod : 0;
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8};
int[] bOffs = {2, 1, 0};
ColorModel colorModel =
new ComponentColorModel(cs, nBits, false, false,
Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
WritableRaster raster =
Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
width * 3 + pad, 3, bOffs, null);
BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);
// Some Windows native applications (e.g. clipbrd.exe) do not understand
// top-down DIBs.
// So we flip the image vertically and create a bottom-up DIB.
AffineTransform imageFlipTransform =
new AffineTransform(1, 0, 0, -1, 0, height);
Graphics2D g2d = bimage.createGraphics();
try {
g2d.drawImage(image, imageFlipTransform, null);
} finally {
g2d.dispose();
}
DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
byte[] imageData = buffer.getData();
return imageDataToPlatformImageBytes(imageData, width, height, format);
}
示例5: setIconImage
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
void setIconImage(Image img) {
if (img == null) {
//if image is null, reset to default image
replaceImage(null);
replaceMask(null);
} else {
//get image size
int width;
int height;
if (img instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)img).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
}
else {
width = img.getWidth(null);
height = img.getHeight(null);
}
Dimension iconSize = getIconSize(width, height);
if (iconSize != null) {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("Icon size: {0}", iconSize);
}
iconWidth = iconSize.width;
iconHeight = iconSize.height;
} else {
log.finest("Error calculating image size");
iconWidth = 0;
iconHeight = 0;
}
replaceImage(img);
replaceMask(img);
}
//create icon window and set XWMHints
XToolkit.awtLock();
try {
AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
awtImageData awtImage = adata.get_awtImage(0);
XVisualInfo visInfo = adata.get_awt_visInfo();
XWMHints hints = parent.getWMHints();
window = hints.get_icon_window();
if (window == 0) {
log.finest("Icon window wasn't set");
XCreateWindowParams params = getDelayedParams();
params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
params.add(BACKGROUND_PIXMAP, iconPixmap);
params.add(COLORMAP, adata.get_awt_cmap());
params.add(DEPTH, awtImage.get_Depth());
params.add(VISUAL_CLASS, (int)XConstants.InputOutput);
params.add(VISUAL, visInfo.get_visual());
params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
params.remove(DELAYED);
init(params);
if (getWindow() == 0) {
log.finest("Can't create new icon window");
} else {
log.finest("Created new icon window");
}
}
if (getWindow() != 0) {
XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
}
// Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
if (getWindow() != 0) {
newFlags |= XUtilConstants.IconWindowHint;
}
hints.set_flags(newFlags);
hints.set_icon_pixmap(iconPixmap);
hints.set_icon_mask(iconMask);
hints.set_icon_window(getWindow());
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), parent.getShell(), hints.pData);
log.finest("Set icon window hint");
} finally {
XToolkit.awtUnlock();
}
}
示例6: setIconImage
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
void setIconImage(Image img) {
if (img == null) {
//if image is null, reset to default image
replaceImage(null);
replaceMask(null);
} else {
//get image size
int width;
int height;
if (img instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)img).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
}
else {
width = img.getWidth(null);
height = img.getHeight(null);
}
Dimension iconSize = getIconSize(width, height);
if (iconSize != null) {
if (log.isLoggable(PlatformLogger.Level.FINEST)) {
log.finest("Icon size: {0}", iconSize);
}
iconWidth = iconSize.width;
iconHeight = iconSize.height;
} else {
log.finest("Error calculating image size");
iconWidth = 0;
iconHeight = 0;
}
replaceImage(img);
replaceMask(img);
}
//create icon window and set XWMHints
XToolkit.awtLock();
try {
AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
awtImageData awtImage = adata.get_awtImage(0);
XVisualInfo visInfo = adata.get_awt_visInfo();
XWMHints hints = parent.getWMHints();
window = hints.get_icon_window();
if (window == 0) {
log.finest("Icon window wasn't set");
XCreateWindowParams params = getDelayedParams();
params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
params.add(BACKGROUND_PIXMAP, iconPixmap);
params.add(COLORMAP, adata.get_awt_cmap());
params.add(DEPTH, awtImage.get_Depth());
params.add(VISUAL_CLASS, XConstants.InputOutput);
params.add(VISUAL, visInfo.get_visual());
params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
params.remove(DELAYED);
init(params);
if (getWindow() == 0) {
log.finest("Can't create new icon window");
} else {
log.finest("Created new icon window");
}
}
if (getWindow() != 0) {
XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
}
// Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
if (getWindow() != 0) {
newFlags |= XUtilConstants.IconWindowHint;
}
hints.set_flags(newFlags);
hints.set_icon_pixmap(iconPixmap);
hints.set_icon_mask(iconMask);
hints.set_icon_window(getWindow());
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), parent.getShell(), hints.pData);
log.finest("Set icon window hint");
} finally {
XToolkit.awtUnlock();
}
}
示例7: imageToPlatformBytes
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
protected byte[] imageToPlatformBytes(Image image, long format)
throws IOException {
String mimeType = null;
if (format == CF_PNG) {
mimeType = "image/png";
} else if (format == CF_JFIF) {
mimeType = "image/jpeg";
}
if (mimeType != null) {
return imageToStandardBytes(image, mimeType);
}
int width = 0;
int height = 0;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
} else {
width = image.getWidth(null);
height = image.getHeight(null);
}
// Fix for 4919639.
// Some Windows native applications (e.g. clipbrd.exe) do not handle
// 32-bpp DIBs correctly.
// As a workaround we switched to 24-bpp DIBs.
// MSDN prescribes that the bitmap array for a 24-bpp should consist of
// 3-byte triplets representing blue, green and red components of a
// pixel respectively. Additionally each scan line must be padded with
// zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
// We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
// with non-default scanline stride and pass the resulting data buffer
// to the native code to fill the BITMAPINFO structure.
int mod = (width * 3) % 4;
int pad = mod > 0 ? 4 - mod : 0;
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8};
int[] bOffs = {2, 1, 0};
ColorModel colorModel =
new ComponentColorModel(cs, nBits, false, false,
Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
WritableRaster raster =
Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
width * 3 + pad, 3, bOffs, null);
BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);
// Some Windows native applications (e.g. clipbrd.exe) do not understand
// top-down DIBs.
// So we flip the image vertically and create a bottom-up DIB.
AffineTransform imageFlipTransform =
new AffineTransform(1, 0, 0, -1, 0, height);
Graphics2D g2d = bimage.createGraphics();
try {
g2d.drawImage(image, imageFlipTransform, null);
} finally {
g2d.dispose();
}
DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
byte[] imageData = buffer.getData();
return imageDataToPlatformImageBytes(imageData, width, height, format);
}
示例8: setIconImage
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
void setIconImage(Image img) {
if (img == null) {
//if image is null, reset to default image
replaceImage(null);
replaceMask(null);
} else {
//get image size
int width;
int height;
if (img instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)img).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
}
else {
width = img.getWidth(null);
height = img.getHeight(null);
}
Dimension iconSize = getIconSize(width, height);
if (iconSize != null) {
log.finest("Icon size: {0}", iconSize);
iconWidth = iconSize.width;
iconHeight = iconSize.height;
} else {
log.finest("Error calculating image size");
iconWidth = 0;
iconHeight = 0;
}
replaceImage(img);
replaceMask(img);
}
//create icon window and set XWMHints
XToolkit.awtLock();
try {
AwtGraphicsConfigData adata = parent.getGraphicsConfigurationData();
awtImageData awtImage = adata.get_awtImage(0);
XVisualInfo visInfo = adata.get_awt_visInfo();
XWMHints hints = parent.getWMHints();
window = hints.get_icon_window();
if (window == 0) {
log.finest("Icon window wasn't set");
XCreateWindowParams params = getDelayedParams();
params.add(BORDER_PIXEL, Long.valueOf(XToolkit.getAwtDefaultFg()));
params.add(BACKGROUND_PIXMAP, iconPixmap);
params.add(COLORMAP, adata.get_awt_cmap());
params.add(DEPTH, awtImage.get_Depth());
params.add(VISUAL_CLASS, (int)XConstants.InputOutput);
params.add(VISUAL, visInfo.get_visual());
params.add(VALUE_MASK, XConstants.CWBorderPixel | XConstants.CWColormap | XConstants.CWBackPixmap);
params.add(PARENT_WINDOW, XlibWrapper.RootWindow(XToolkit.getDisplay(), visInfo.get_screen()));
params.add(BOUNDS, new Rectangle(0, 0, iconWidth, iconHeight));
params.remove(DELAYED);
init(params);
if (getWindow() == 0) {
log.finest("Can't create new icon window");
} else {
log.finest("Created new icon window");
}
}
if (getWindow() != 0) {
XlibWrapper.XSetWindowBackgroundPixmap(XToolkit.getDisplay(), getWindow(), iconPixmap);
XlibWrapper.XClearWindow(XToolkit.getDisplay(), getWindow());
}
// Provide both pixmap and window, WM or Taskbar will use the one they find more appropriate
long newFlags = hints.get_flags() | XUtilConstants.IconPixmapHint | XUtilConstants.IconMaskHint;
if (getWindow() != 0) {
newFlags |= XUtilConstants.IconWindowHint;
}
hints.set_flags(newFlags);
hints.set_icon_pixmap(iconPixmap);
hints.set_icon_mask(iconMask);
hints.set_icon_window(getWindow());
XlibWrapper.XSetWMHints(XToolkit.getDisplay(), parent.getShell(), hints.pData);
log.finest("Set icon window hint");
} finally {
XToolkit.awtUnlock();
}
}
示例9: imageToPlatformBytes
import sun.awt.image.ImageRepresentation; //导入方法依赖的package包/类
protected byte[] imageToPlatformBytes(Image image, long format)
throws IOException {
String mimeType = null;
if (format == CF_PNG) {
mimeType = "image/png";
} else if (format == CF_JFIF) {
mimeType = "image/jpeg";
}
if (mimeType != null) {
return imageToStandardBytes(image, mimeType);
}
int width = 0;
int height = 0;
if (image instanceof ToolkitImage) {
ImageRepresentation ir = ((ToolkitImage)image).getImageRep();
ir.reconstruct(ImageObserver.ALLBITS);
width = ir.getWidth();
height = ir.getHeight();
} else {
width = image.getWidth(null);
height = image.getHeight(null);
}
// Fix for 4919639.
// Some Windows native applications (e.g. clipbrd.exe) do not handle
// 32-bpp DIBs correctly.
// As a workaround we switched to 24-bpp DIBs.
// MSDN prescribes that the bitmap array for a 24-bpp should consist of
// 3-byte triplets representing blue, green and red components of a
// pixel respectively. Additionally each scan line must be padded with
// zeroes to end on a LONG data-type boundary. LONG is always 32-bit.
// We render the given Image to a BufferedImage of type TYPE_3BYTE_BGR
// with non-default scanline stride and pass the resulting data buffer
// to the native code to fill the BITMAPINFO structure.
int mod = (width * 3) % 4;
int pad = mod > 0 ? 4 - mod : 0;
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
int[] nBits = {8, 8, 8};
int[] bOffs = {2, 1, 0};
ColorModel colorModel =
new ComponentColorModel(cs, nBits, false, false,
Transparency.OPAQUE, DataBuffer.TYPE_BYTE);
WritableRaster raster =
Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE, width, height,
width * 3 + pad, 3, bOffs, null);
BufferedImage bimage = new BufferedImage(colorModel, raster, false, null);
// Some Windows native applications (e.g. clipbrd.exe) do not understand
// top-down DIBs.
// So we flip the image vertically and create a bottom-up DIB.
AffineTransform imageFlipTransform =
new AffineTransform(1, 0, 0, -1, 0, height);
Graphics2D g2d = bimage.createGraphics();
try {
g2d.drawImage(image, imageFlipTransform, null);
} finally {
g2d.dispose();
}
DataBufferByte buffer = (DataBufferByte)raster.getDataBuffer();
byte[] imageData = buffer.getData();
return imageDataToPlatformImageBytes(imageData, width, height, format);
}