Browse Source

- add DDS support to texture browser (thanks to @destroflyer!)

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@6992 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 14 years ago
parent
commit
c4df426638

+ 4 - 0
jme3-core/nbproject/project.xml

@@ -258,6 +258,10 @@
                 <package>com.jme3.gde.core.undoredo</package>
                 <package>com.jme3.gde.core.util</package>
             </public-packages>
+            <class-path-extension>
+                <runtime-relative-path>ext/DDSUtils.jar</runtime-relative-path>
+                <binary-origin>release/modules/ext/DDSUtils.jar</binary-origin>
+            </class-path-extension>
         </data>
     </configuration>
 </project>

BIN
jme3-core/release/modules/ext/DDSUtils.jar


+ 20 - 1
jme3-core/src/com/jme3/gde/core/sceneexplorer/nodes/properties/TextureBrowser.java

@@ -31,12 +31,19 @@
  */
 package com.jme3.gde.core.sceneexplorer.nodes.properties;
 
+import Model.DDSImageFile;
 import com.jme3.gde.core.assets.ProjectAssetManager;
 import com.jme3.texture.Texture;
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
 import java.util.logging.Logger;
 import javax.swing.DefaultListSelectionModel;
 import javax.swing.Icon;
+import javax.swing.ImageIcon;
 import jme3tools.converters.ImageToAwt;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
 import org.openide.util.ImageUtilities;
 
 /**
@@ -199,7 +206,19 @@ public class TextureBrowser extends javax.swing.JDialog {
         if (textureList.getSelectedIndex() > -1) {
             String selected = (String) textureList.getSelectedValue();
             Texture tex = assetManager.loadTexture(selected);
-            Icon newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
+            Icon newicon = null;
+            if(selected.endsWith(".dds")||selected.endsWith(".DDS")){
+                try {
+                    File file = FileUtil.toFile(assetManager.getAssetFolder().getFileObject(selected));
+                    DDSImageFile ddsImageFile = new DDSImageFile(file);
+                    BufferedImage bufferedImage = ddsImageFile.getData();
+                    newicon = new ImageIcon(bufferedImage);
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
+            }else{
+                 newicon = ImageUtilities.image2Icon(ImageToAwt.convert(tex.getImage(), false, true, 0));
+            }
             imagePreviewLabel.setIcon(newicon);
         } else {
             imagePreviewLabel.setIcon(null);