简体   繁体   English

Java启动画面比例因子

[英]Java Splash Screen scale factor

Java seems to scale the splash screen passed as a jvm switch eg Java似乎可以缩放作为jvm开关传递的启动屏幕,例如

java -splash:splash_file.png java -splash:splash_file.png

depending on the size of the monitor. 取决于显示器的尺寸。

On the source i can see a reference to some natively calculated scale factor. 在来源上,我可以看到对某些本地计算的比例因子的引用。 Does anybody know how this scaling factor is calculated? 有人知道该比例因子是如何计算的吗?

I would assume it's calculated by the standard way for graphics which takes an image of a given size in an unbounded "world" (world coordinates), transforms it to a normalized device (think unit square), and then transforms it again to the screen coordinates. 我假设它是通过图形的标准方法计算的,该方法在无界的“世界”(世界坐标)中获取给定大小的图像,将其转换为归一化的设备(认为单位平方),然后再次将其转换为屏幕坐标。 The transformations consist of a translation and a scaling of the points. 转换包括点的平移和缩放。

Given the splash screen's window in the world (the way it should appear without translation or scaling), the normalized (x,y) values are obtained as follows: 给定初始屏幕的世界窗口(在没有平移或缩放的情况下其显示方式),可以按以下方式获得标准化的(x,y)值:

The first part is the translation and the second the scale factor. 第一部分是平移,第二部分是比例因子。 This reduces the image to be contained in a 1 x 1 square so all the (x,y) values are fractional. 这样可以减少图像包含在1 x 1的正方形中,因此所有(x,y)值都是分数。

To go from the normalized to screen coordinate system the values are calculated as follows: 要从归一化坐标系转换为屏幕坐标系,请按以下方式计算值:

These operations are typically done efficiently with the help of translation and scaling matrix multiplications. 这些操作通常在转换和缩放矩阵乘法的帮助下有效完成。 Rotation can also be applied. 也可以旋转。

This is actually a low-level view of how you could take images, shapes, etc. drawn anyway you like and present them consistently across any sized screens. 这实际上是一个底层视图,显示了如何拍摄自己喜欢的图像,形状等,并在所有尺寸的屏幕上一致地呈现它们。 I'm not sure exactly how it's done in the example you give but it would likely be some variation of this. 我不确定在您给出的示例中它是如何完成的,但可能会有所不同。 See the beginning of this presentation for a visual representation. 请参阅本演示文稿的开头以直观表示。

This value is actually both jdk implementation-dependent and architecture-dependent. 该值实际上既取决于jdk实现,也取决于体系结构。

I browsed the OpenJDK code , and for a lot of architectures, it's simply hardcoded to 1. 我浏览了OpenJDK代码 ,对于许多体系结构,它都被简单地硬编码为1。

For example, in the windows bindings, you'll find: 例如,在Windows绑定中,您将找到:

SPLASHEXPORT char*
SplashGetScaledImageName(const char* jarName, const char* fileName,
                       float *scaleFactor)
{
    *scaleFactor = 1;
    return   NULL;
}

The scaleFactor value is then stored into a struct that is accessed via JNI through the _GetScaleFactor method. 然后将scaleFactor值存储到通过_GetScaleFactor方法通过JNI访问的结构中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM