Player icon indicating copy to clipboard operation
Player copied to clipboard

Picture scale differences

Open gadesx opened this issue 10 years ago • 16 comments

The picture representation using scale are different, and with 50scale it show less size

comparison

Test case: http://dl.dropboxusercontent.com/u/22524283/rpg%20maker/easy/Tests%20case%2001.rar

gadesx avatar Mar 26 '15 19:03 gadesx

@gadesx the dropbox link is broken. Could you reupload the test case here where possible?

fdelapena avatar Jul 10 '18 22:07 fdelapena

its impossible for me reupload that without internet in home, but you can make a picture similar and test with player.

gadesx avatar Jul 14 '18 19:07 gadesx

added [Needs Feedback] until a new example is available.

I'm pretty sure I saw a while ago some prepared image that either showed an Apple or Nothing depending on the resize algorithm of the web browser used, would be a nice test case but I can't find it anymore.

Ghabry avatar Jul 27 '18 18:07 Ghabry

The old test case, maybe works fine with actual player. Tests case 01.zip

gadesx avatar Oct 18 '18 20:10 gadesx

This was also noticed in #2133 for battle gauges. Leaving a note here

mateofio avatar Apr 13 '20 01:04 mateofio

One way to test if the battle gauges scale correctly is using the System2C graphics from the RTP. The right end of the gauge must become diagonal upon reaching 16 out of 25.

@Ghabry mentioned a possible solution for this issue in https://github.com/EasyRPG/Player/issues/2519#issuecomment-833009899.

ghost avatar May 09 '21 17:05 ghost

I have bad news here: I dug deeper into the source code of pixman and found out that there are no settings which affect the rounding. This means to fix this issue we have to make a custom build of pixman which has the rounding changed the way like RPG_RT does. For a possible fix for the rounding see this comment.

ghost avatar Jun 10 '21 19:06 ghost

You can cheat a bit by translating the image before the scaling. Though for the issue in here with the 50% this fixes nothing.

With that code, when a picture is shown, you can use NUM+ and NUM- to adjust the offset.

When you set it to "-4" for the Yume2kki issue than the images are blitted correctly. You could try playing around with this for the gauge.

// belongs in Bitmap::StretchBlit
	static int i = 0;

	if (Input::IsTriggered(Input::PLUS)) {
		++i;
		Output::Debug("{}", i);
	} else if (Input::IsTriggered(Input::MINUS)) {
		--i;
		Output::Debug("{}", i);
	}

	Transform xform = Transform::Translation(i, i);
	xform *= Transform::Scale(zoom_x, zoom_y);

Ghabry avatar Jun 10 '21 21:06 Ghabry

Translation the gauge by "1, 0" before scaling makes the gauge pixel perfect but then you have obviously an offset in there, making the rest look wrong.

Ghabry avatar Jun 10 '21 21:06 Ghabry

Small summary: We have got two issues here which make scaled pictures look not pixel perfect:

First issue: RPG_RT selecting top left corner pixel instead of nearest neighbor pixel. To fix this one a custom build of pixman is needed. You have to change line 480 from pixman-inlines.h to v.vector[0] = pixman_int_to_fixed (src_x) + pixman_fixed_e * 72;, line 481 from pixman-inlines.h to v.vector[1] = pixman_int_to_fixed (src_y) + pixman_fixed_e * 72; and remove lines 490-492 from pixman-inlines.h. These changes fixes the gauge display in RPG Maker 2003 battles and the pictures mentioned in #2519.

Second issue: RPG_RT downscaling calculation issues. RPG_RT does some weird calculations on scaling down, the picture from the OP has a size of 158x158. In RPG_RT the 50% scale scales it down to 80x80 (where we would expect 79x79). By scaling the picture to 80x80 with the pixman change, the output is exactly the same as in RPG_RT. So we have to find out why RPG_RT scales 158 down to 80 instead of 79 at 50% scale.

ghost avatar Jun 12 '21 06:06 ghost

RPG_RT really does use a weird scaling algorithm,

here the table for a 100x100 sized picture
Scale factor Picture size
0% 0x0
1% 2x2
2% 2x2
3% 2x2
4% 4x4
5% 6x6
6% 6x6
7% 8x8
8% 8x8
9% 8x8
10% 10x10
11% 12x12
12% 12x12
13% 14x14
14% 14x14
15% 14x14
16% 16x16
17% 18x18
18% 18x18
19% 20x20
20% 20x20
21% 20x20
22% 22x22
23% 24x24
24% 24x24
25% 24x24
26% 26x26
27% 28x28
28% 28x28
29% 28x28
30% 30x30
31% 30x30
32% 32x32
33% 34x34
34% 34x34
35% 34x34
36% 36x36
37% 36x36
38% 38x38
39% 40x40
40% 40x40
41% 40x40
42% 42x42
43% 42x42
44% 44x44
45% 46x46
46% 46x46
47% 46x46
48% 48x48
49% 48x48
50% 50x50
51% 52x52
52% 52x52
53% 54x54
54% 54x54
55% 56x56
56% 56x56
57% 56x56
58% 58x58
59% 58x58
60% 60x60
61% 60x60
62% 62x62
63% 64x64
64% 64x64
65% 66x66
66% 66x66
67% 68x68
68% 68x68
69% 68x68
70% 70x70
71% 70x70
72% 72x72
73% 72x72
74% 74x74
75% 76x76
76% 76x76
77% 78x78
78% 78x78
79% 80x80
80% 80x80
81% 82x82
82% 82x82
83% 82x82
84% 84x84
85% 84x84
86% 86x86
87% 86x86
88% 88x88
89% 90x90
90% 90x90
91% 92x92
92% 92x92
93% 94x94
94% 94x94
95% 94x94
96% 96x96
97% 96x96
98% 98x98
99% 98x98
100% 100x100
101% 102x102
102% 102x102
103% 104x104
104% 104x104
105% 106x106
106% 106x106
107% 108x108
108% 108x108
109% 110x110
110% 110x110
111% 112x112
112% 112x112
113% 112x112
114% 114x114
115% 114x114
116% 116x116
117% 116x116
118% 118x118
119% 118x118
120% 120x120

ghost avatar Sep 18 '21 12:09 ghost

Found out that RPG_RT always scales the width and height of the picture to a value which can be divided by 2 without remainder unless the scale factor is set to exactly 100% with the "Show Picture" command.

ghost avatar Sep 18 '21 14:09 ghost

This is done so that scaling will not result in an effect of the picture moving by one pixel in some direction.

CherryDT avatar Apr 13 '23 14:04 CherryDT

to add to this I tried doing scale at 8000% for whatever reason and it looks less zoomed in on Easy RPG as opposed to RPG_RT Maybe the zoom goes less higher?

choinheap avatar Sep 11 '23 13:09 choinheap

Maybe a limitation in the Pixman library we use for rendering.

Ghabry avatar Sep 13 '23 20:09 Ghabry