Browse Source

feat: ui 支持alpha缩放

hexleo 5 years ago
parent
commit
05449a6d72

+ 3 - 7
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/CommonArg.java

@@ -23,13 +23,13 @@ public class CommonArg {
 
     public String mp4editCmd = "mp4edit"; // bento4 mp4edit 命令地址
 
-    public boolean enableH265 = false; // 是否开启h265
+    public boolean enableH265 = true; // 是否开启h265
 
-    public int fps = 0;
+    public int fps = 24;
 
     public String inputPath; // 输入帧文件地址
 
-    public float scale = 1f; // alpha 区域缩放大小
+    public float scale = 0.5f; // alpha 区域缩放大小
 
     /**
      * 自动填充参数配置
@@ -42,10 +42,6 @@ public class CommonArg {
 
     public int gap; // rgb 与 alpha 之间间隔距离
 
-    // public int wFill; // 宽度填充
-
-    // public int hFill; // 高度填充
-
     public int totalFrame;
 
     public PointRect rgbPoint = new PointRect(); // rgb 区域 原始图像区域

+ 3 - 4
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/Main.java

@@ -23,9 +23,9 @@ public class Main {
 
     public static void main(String[] args) throws Exception {
         // 启动UI界面
-        // new ToolUI().run();
+        new ToolUI().run();
         // java工具
-        animTool();
+        // animTool();
     }
 
 
@@ -66,8 +66,7 @@ public class Main {
         // fps
         commonArg.fps = 24;
         // 素材文件路径
-        // commonArg.inputPath = "/path/to/your/demo";
-        commonArg.inputPath = "/Users/hexleo/temp/moon/DemoH/video";
+        commonArg.inputPath = "/path/to/your/demo";
         // alpha 区域缩放大小  (0.5 - 1)
         commonArg.scale = 0.5f;
 

+ 37 - 4
Android/PlayerProj/animtool/src/main/java/com/tencent/qgame/playerproj/animtool/ui/ToolUI.java

@@ -22,6 +22,7 @@ import java.util.Properties;
 import javax.swing.BoxLayout;
 import javax.swing.ButtonGroup;
 import javax.swing.JButton;
+import javax.swing.JComboBox;
 import javax.swing.JFileChooser;
 import javax.swing.JFrame;
 import javax.swing.JLabel;
@@ -45,6 +46,8 @@ public class ToolUI {
     private final JRadioButton btnH265 = new JRadioButton("h265");
     private final JRadioButton btnH264 = new JRadioButton("h264");
     private final SpinnerModel modelFps = new SpinnerNumberModel(24, 1, 60, 1);
+    private final Float[] scaleArray = new Float[]{0.5f, 1f};
+    private final JComboBox<Float> boxScale = new JComboBox<>(scaleArray);
     private final JTextField textInputPath = new JTextField();
     private final JButton btnCreate = new JButton("create VAP");
     private final JTextArea txtAreaLog = new JTextArea();
@@ -72,6 +75,13 @@ public class ToolUI {
             group.setSelected(commonArg.enableH265 ? btnH265.getModel() : btnH264.getModel(), true);
             modelFps.setValue(commonArg.fps);
             textInputPath.setText(commonArg.inputPath);
+            float scale = commonArg.scale;
+            for (int i=0; i<scaleArray.length ; i++) {
+                if (scaleArray[i] == scale) {
+                    boxScale.setSelectedIndex(i);
+                    break;
+                }
+            }
         } catch (Exception e) {
             TLog.i(TAG, "ERROR -> " + e.getMessage());
         }
@@ -112,6 +122,8 @@ public class ToolUI {
         commonArg.enableH265 = group.isSelected(btnH265.getModel());
         commonArg.fps = (Integer)modelFps.getValue();
         commonArg.inputPath = textInputPath.getText();
+        commonArg.scale = scaleArray[boxScale.getSelectedIndex()];
+
         TLog.i(TAG, commonArg.toString());
 
         AnimTool animTool = new AnimTool();
@@ -166,6 +178,8 @@ public class ToolUI {
         panel.add(getCodecLayout());
         // fps
         panel.add(getFpsLayout());
+        // scale
+        panel.add(getScaleLayout());
         // path
         panel.add(getPathLayout());
         // create
@@ -209,6 +223,17 @@ public class ToolUI {
         return panel;
     }
 
+    private JPanel getScaleLayout() {
+        JPanel panel = new JPanel();
+        panel.setLayout(new FlowLayout(FlowLayout.LEFT));
+        JLabel label = new JLabel("alpha scale");
+        label.setPreferredSize(labelSize);
+        panel.add(label);
+
+        panel.add(boxScale);
+        return panel;
+    }
+
     private JPanel getPathLayout() {
         JPanel panel = new JPanel();
 
@@ -317,25 +342,33 @@ public class ToolUI {
 
     private CommonArg getProperties() {
         CommonArg commonArg = new CommonArg();
+        String version = props.getProperty("version", "0");
         String enableH265 = props.getProperty("enableH265", Boolean.TRUE.toString());
-        String fps = props.getProperty("fps", "24");
+        String fps = props.getProperty("fps", String.valueOf(commonArg.fps));
         String inputPath = props.getProperty("inputPath", "");
+        String scale = props.getProperty("scale", String.valueOf(scaleArray[0]));
 
-        commonArg.enableH265 = Boolean.TRUE.toString().equals(enableH265);
         try {
+            int v = Integer.parseInt(version);
+            // 版本不符直接返回默认值
+            if (v != commonArg.version) return commonArg;
             commonArg.fps = Integer.parseInt(fps);
+            commonArg.scale = Float.parseFloat(scale);
+            commonArg.enableH265 = Boolean.TRUE.toString().equals(enableH265);
+            commonArg.inputPath = inputPath;
         } catch (Exception e) {
-            commonArg.fps = 24;
+            TLog.i(TAG, "getProperties error:" + e.getMessage());
         }
-        commonArg.inputPath = inputPath;
         return commonArg;
     }
 
 
     private void setProperties(CommonArg commonArg) throws IOException {
+        props.setProperty("version", commonArg.version + "");
         props.setProperty("enableH265", commonArg.enableH265? Boolean.TRUE.toString() : Boolean.FALSE.toString());
         props.setProperty("fps", commonArg.fps + "");
         props.setProperty("inputPath", commonArg.inputPath == null ? "" : commonArg.inputPath);
+        props.setProperty("scale", commonArg.scale + "");
         props.store(new FileOutputStream(PROPERTIES_FILE), "");
     }