本文整理汇总了Java中jme3tools.converters.ImageToAwt类的典型用法代码示例。如果您正苦于以下问题:Java ImageToAwt类的具体用法?Java ImageToAwt怎么用?Java ImageToAwt使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageToAwt类属于jme3tools.converters包,在下文中一共展示了ImageToAwt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readJMETexture
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
@FXThread
private @NotNull Image readJMETexture(final int width, final int height, @NotNull final String externalForm,
@NotNull final Path cacheFile) {
final Editor editor = Editor.getInstance();
final AssetManager assetManager = editor.getAssetManager();
final Texture texture = assetManager.loadTexture(externalForm);
final BufferedImage textureImage;
try {
textureImage = ImageToAwt.convert(texture.getImage(), false, true, 0);
} catch (final UnsupportedOperationException e) {
EditorUtil.handleException(LOGGER, this, e);
return Icons.IMAGE_512;
}
final int imageWidth = textureImage.getWidth();
final int imageHeight = textureImage.getHeight();
return scaleAndWrite(width, height, cacheFile, textureImage, imageWidth, imageHeight);
}
示例2: saveIfNeedTexture
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
/**
* Save if need a texture.
*
* @param texture the texture.
*/
private static void saveIfNeedTexture(@NotNull final Texture texture) {
final Image image = texture.getImage();
if (!image.isChanged()) return;
final AssetKey key = texture.getKey();
final Path file = notNull(getRealFile(key.getName()));
final BufferedImage bufferedImage = ImageToAwt.convert(image, false, true, 0);
try (final OutputStream out = Files.newOutputStream(file, WRITE, TRUNCATE_EXISTING, CREATE)) {
ImageIO.write(bufferedImage, "png", out);
} catch (final IOException e) {
e.printStackTrace();
}
image.clearChanges();
}
示例3: scale
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
@Override
public void scale(int width, int height) {
if (width < 0 && height < 0) {
return;
} else if (width < 0) {
width = Math.round(width
* (height == 0 ? 1 : ((float) height / height)));
} else if (height < 0) {
height = Math.round(height
* (width == 0 ? 1 : ((float) width / width)));
}
BufferedImage bim = ImageToAwt.convert(image, false, true, 0);
System.err.println("scaling image from " + image.getWidth() + " x " + image.getHeight() + " to " + width + " x " + height);
BufferedImage tbim = new BufferedImage(width, height, bim.getType());
tbim.getGraphics().drawImage(bim, 0, 0, width, height, null);
image = new AWTLoader().load(tbim, false);
}
示例4: scale
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
/**
* This method scales the given texture to the given size.
*
* @param texture
* the texture to be scaled
* @param width
* new width of the texture
* @param height
* new height of the texture
*/
private void scale(Texture2D texture, int width, int height) {
// first determine if scaling is required
boolean scaleRequired = texture.getImage().getWidth() != width || texture.getImage().getHeight() != height;
if (scaleRequired) {
Image image = texture.getImage();
BufferedImage sourceImage = ImageToAwt.convert(image, false, true, 0);
int sourceWidth = sourceImage.getWidth();
int sourceHeight = sourceImage.getHeight();
BufferedImage targetImage = new BufferedImage(width, height, sourceImage.getType());
Graphics2D g = targetImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(sourceImage, 0, 0, width, height, 0, 0, sourceWidth, sourceHeight, null);
g.dispose();
Image output = new ImageLoader().load(targetImage, false);
image.setWidth(width);
image.setHeight(height);
image.setData(output.getData(0));
image.setFormat(output.getFormat());
}
}
示例5: multipleTexSouthLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexSouthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexSouthLoadButtonActionPerformed
Component view = editorSouth.getCustomEditor();
view.setVisible(true);
if (editorSouth.getValue() != null) {
Texture tex = (Texture) editorSouth.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, southPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
southPic.setIcon(newicon);
}
}
}
示例6: multipleTexNorthLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexNorthLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexNorthLoadButtonActionPerformed
Component view = editorNorth.getCustomEditor();
view.setVisible(true);
if (editorNorth.getValue() != null) {
Texture tex = (Texture) editorNorth.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, northPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
northPic.setIcon(newicon);
}
}
}
示例7: multipleTexEastLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexEastLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexEastLoadButtonActionPerformed
Component view = editorEast.getCustomEditor();
view.setVisible(true);
if (editorEast.getValue() != null) {
Texture tex = (Texture) editorEast.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, eastPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
eastPic.setIcon(newicon);
}
}
}
示例8: multipleTexWestLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexWestLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexWestLoadButtonActionPerformed
Component view = editorWest.getCustomEditor();
view.setVisible(true);
if (editorWest.getValue() != null) {
Texture tex = (Texture) editorWest.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, westPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
westPic.setIcon(newicon);
}
}
}
示例9: multipleTexTopLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexTopLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexTopLoadButtonActionPerformed
Component view = editorTop.getCustomEditor();
view.setVisible(true);
if (editorTop.getValue() != null) {
Texture tex = (Texture) editorTop.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, topPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
topPic.setIcon(newicon);
}
}
}
示例10: multipleTexBottomLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void multipleTexBottomLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_multipleTexBottomLoadButtonActionPerformed
Component view = editorBottom.getCustomEditor();
view.setVisible(true);
if (editorBottom.getValue() != null) {
Texture tex = (Texture) editorBottom.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, bottomPic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
bottomPic.setIcon(newicon);
}
}
}
示例11: singleTexLoadButtonActionPerformed
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void singleTexLoadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_singleTexLoadButtonActionPerformed
Component view = editorSingle.getCustomEditor();
view.setVisible(true);
if (editorSingle.getValue() != null) {
Texture tex = (Texture) editorSingle.getValue();
String selected = tex.getKey().getName();
if (selected.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview((ProjectAssetManager) SceneApplication.getApplication().getAssetManager());
}
ddsPreview.requestPreview(selected, "", 80, 80, singlePic, null);
} else {
Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
singlePic.setIcon(newicon);
}
}
}
示例12: convertToNormalMapTexture
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
/**
* This method converts the given texture into normal-map texture.
*
* @param source
* the source texture
* @param strengthFactor
* the normal strength factor
* @return normal-map texture
*/
public Image convertToNormalMapTexture(Image source, float strengthFactor) {
BufferedImage sourceImage = ImageToAwt.convert(source, false, false, 0);
BufferedImage heightMap = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
BufferedImage bumpMap = new BufferedImage(sourceImage.getWidth(), sourceImage.getHeight(), BufferedImage.TYPE_INT_ARGB);
ColorConvertOp gscale = new ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
gscale.filter(sourceImage, heightMap);
Vector3f S = new Vector3f();
Vector3f T = new Vector3f();
Vector3f N = new Vector3f();
for (int x = 0; x < bumpMap.getWidth(); ++x) {
for (int y = 0; y < bumpMap.getHeight(); ++y) {
// generating bump pixel
S.x = 1;
S.y = 0;
S.z = strengthFactor * this.getHeight(heightMap, x + 1, y) - strengthFactor * this.getHeight(heightMap, x - 1, y);
T.x = 0;
T.y = 1;
T.z = strengthFactor * this.getHeight(heightMap, x, y + 1) - strengthFactor * this.getHeight(heightMap, x, y - 1);
float den = (float) Math.sqrt(S.z * S.z + T.z * T.z + 1);
N.x = -S.z;
N.y = -T.z;
N.z = 1;
N.divideLocal(den);
// setting thge pixel in the result image
bumpMap.setRGB(x, y, this.vectorToColor(N.x, N.y, N.z));
}
}
ByteBuffer byteBuffer = BufferUtils.createByteBuffer(source.getWidth() * source.getHeight() * 3);
ImageToAwt.convert(bumpMap, Format.RGB8, byteBuffer);
return new Image(Format.RGB8, source.getWidth(), source.getHeight(), byteBuffer);
}
示例13: castToUVS
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
/**
* This method alters the images to fit them into UV coordinates of the
* given target texture.
*
* @param targetTexture
* the texture to whose UV coordinates we fit current images
* @param blenderContext
* the blender context
*/
public void castToUVS(TriangulatedTexture targetTexture, BlenderContext blenderContext) {
int[] sourceSize = new int[2], targetSize = new int[2];
ImageLoader imageLoader = new ImageLoader();
TextureHelper textureHelper = blenderContext.getHelper(TextureHelper.class);
for (TriangleTextureElement entry : faceTextures) {
TriangleTextureElement targetFaceTextureElement = targetTexture.getFaceTextureElement(entry.faceIndex);
Vector2f[] dest = targetFaceTextureElement.uv;
// get the sizes of the source and target images
sourceSize[0] = entry.image.getWidth();
sourceSize[1] = entry.image.getHeight();
targetSize[0] = targetFaceTextureElement.image.getWidth();
targetSize[1] = targetFaceTextureElement.image.getHeight();
// create triangle transformation
AffineTransform affineTransform = textureHelper.createAffineTransform(entry.uv, dest, sourceSize, targetSize);
// compute the result texture
BufferedImage sourceImage = ImageToAwt.convert(entry.image, false, true, 0);
BufferedImage targetImage = new BufferedImage(targetSize[0], targetSize[1], sourceImage.getType());
Graphics2D g = targetImage.createGraphics();
g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
g.drawImage(sourceImage, affineTransform, null);
g.dispose();
Image output = imageLoader.load(targetImage, false);
entry.image = output;
entry.uv[0].set(dest[0]);
entry.uv[1].set(dest[1]);
entry.uv[2].set(dest[2]);
}
}
示例14: displayPreview
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
private void displayPreview() {
if (!"".equals(textureName)) {
Texture tex = manager.loadTexture(textureName);
Icon newicon = null;
if (textureName.toLowerCase().endsWith(".dds")) {
if (ddsPreview == null) {
ddsPreview = new DDSPreview(manager);
}
ddsPreview.requestPreview(textureName, "", 80, 80, texturePreview, null);
} else {
newicon = ImageUtilities.image2Icon(resizeImage(ImageToAwt.convert(tex.getImage(), false, true, 0)));
}
texturePreview.setIcon(newicon);
}
}
示例15: doSaveAlphaImages
import jme3tools.converters.ImageToAwt; //导入依赖的package包/类
/**
* Save the terrain's alpha maps to disk, in the Textures/terrain-alpha/ directory
* @throws IOException
*/
private synchronized void doSaveAlphaImages(Terrain terrain) {
if (terrain == null) {
getTerrain(rootNode);
return;
}
AssetManager manager = SceneApplication.getApplication().getAssetManager();
String assetFolder = null;
if (manager != null && manager instanceof ProjectAssetManager)
assetFolder = ((ProjectAssetManager)manager).getAssetFolderName();
if (assetFolder == null)
throw new IllegalStateException("AssetManager was not a ProjectAssetManager. Could not locate image save directories.");
Texture alpha1 = doGetAlphaTexture(terrain, 0);
BufferedImage bi1 = ImageToAwt.convert(alpha1.getImage(), false, true, 0);
File imageFile1 = new File(assetFolder+alpha1.getKey().getName());
Texture alpha2 = doGetAlphaTexture(terrain, 1);
BufferedImage bi2 = ImageToAwt.convert(alpha2.getImage(), false, true, 0);
File imageFile2 = new File(assetFolder+alpha2.getKey().getName());
Texture alpha3 = doGetAlphaTexture(terrain, 2);
BufferedImage bi3 = ImageToAwt.convert(alpha3.getImage(), false, true, 0);
File imageFile3 = new File(assetFolder+alpha3.getKey().getName());
try {
ImageIO.write(bi1, "png", imageFile1);
ImageIO.write(bi2, "png", imageFile2);
ImageIO.write(bi3, "png", imageFile3);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}