Swing - Jpanel 中的图像在大屏幕上看起来很模糊

时间:2021-04-20 13:03:27

标签: java swing

在 JPanel 内的登录屏幕上显示了一个徽标图像。此图像在大监视器屏幕上看起来很模糊。谁能告诉我如何解决图像模糊的问题,使图像在大屏幕上看起来清晰锐利?

  1. 我是否必须制作高分辨率图像并根据屏幕尺寸缩小?

以下是按比例调整图片大小的方法。

using System;
using System.Collections.Generic;
using Microsoft.ML.Data;
using Microsoft.ML;

namespace Test
{
    class LstmCellInput
    {
        [ColumnName("attributes")]
        [VectorType(1,1,8)]
        public float[] Attributes { get; set; }

        [ColumnName("h_in")]
        [VectorType(1, 1, 16)]
        public float[] HiddenState { get; set; }

        [ColumnName("c_in")]
        [VectorType(1, 1, 16)]
        public float[] CellState { get; set; }
    }

    class LSTMCellOutput
    {
        [ColumnName("prediction")]
        [VectorType(1, 1, 1)]
        public float[] Prediction { get; set; }

        [ColumnName("h_out")]
        [VectorType(1, 1, 16)]
        public float[] HiddenState { get; set; }

        [ColumnName("c_out")]
        [VectorType(1, 1, 16)]
        public float[] CellState { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadKey();
            Console.WriteLine("start");

            var x = new LstmCellInput {
                HiddenState = new float[16],
                CellState = new float[16],
                Attributes = new float[8]
            };
            
            // link for "celllstm.onnx" : https://drive.google.com/file/d/1dBgbJm6Bo1gLBMH3IEmnpRnLDLAw0VC2/view?usp=sharing
            var context = new MLContext();
                var transforms = context.Transforms.ApplyOnnxModel(
                    modelFile: "celllstm.onnx",
                    inputColumnNames: new String[] { "attributes", "h_in", "c_in" },
                    outputColumnNames: new String[] { "prediction", "h_out", "c_out" }
                );

            var model = transforms.Fit(context.Data.LoadFromEnumerable(new List<LstmCellInput>()));
            var engine = context.Model.CreatePredictionEngine<LstmCellInput, LSTMCellOutput>(model);
            
            for (int i = 0; i < 5000; i++)
            {
                var y = engine.Predict(x);                
            }

            model.Dispose();
            engine.Dispose();
            Console.WriteLine("finish");
            Console.ReadKey();
        }
    }
}

这里如何根据屏幕尺寸计算新的高度和宽度作为参数传递? 谢谢。

0 个答案:

没有答案