Using ImageRectOffset/ImageRectSize shrinks an image on larger screen resolutions

In the game I’m working on, there are images that are rendering off/center and shrunk on large monitors, which used to work perfectly fine. This is a recent change we only noticed today, and does not happen on mobile.

When I check for the size, the image is scaled to cover the entire purple box. The image is arranged into a spritesheet for memory optimization, and is using ImageRectOffset/ImageRectSize to only select a portion of the spritesheet. On all low-mid resolution devices, this appears normal


On smaller monitors and on scaled mobile sizes (480p for example), the image scales down correctly to cover the whole screen

However, once the image takes up more than 204x204 of screen space, it gets shrunken down on the bottom right

For other images that do not use a spritesheet, the icon looks perfectly fine. This bug only appears if ImageRectSize is defined and if the image is scaled to a larger pixel space than the ImageRectSize

This happens on both Windows and macOS, have not seen it happen on mobile so far (probably due to the DPI scaling on mobile)

This issue was first detected today, and has not happened before on high-resolution desktop devices until now.

1 Like

Hi, thanks for reporting this!

Would you be able to post a minimal repro file?

I was also wondering what GuiObject type the image is, ImageLabel or ImageButton? Also, what is the ScaleType set to?

Sent you a DM with the repro.

Looks like this is an ImageLabel with a Slice ScaleType and a SliceCenter property of 0, 0, 0, 0 which disabled the 9-slice functionality

Changing the ScaleType to Crop seemed to fix the issue.

1 Like

Hi, glad to hear that you were able to fix the issue by changing the ScaleType!

I noticed you said in your original post that this “used to work perfectly fine.” Can you confirm that you had ScaleType=Slice before, and SliceCenter=0, 0, 0, 0, and the image scaled arbitrarily large before?
I just wanted to check we didn’t have a regression/change with 9-slice behavior.

The current 9-slice behavior is that setting ScaleType=Slice and SliceCenter=0, 0, 0, 0 doesn’t actually disable 9-slice. These settings create a 9-slice image where slices 1, 2, 4, and 5 are the color of the top left pixel in your image. You can check the slice boundaries by opening the 9-slice editor by clicking the “…” button in SliceCenter.

So then you would get the expected result that most of the image is in the bottom right corner (slice 9). To learn more about 9-slice, please check out this tutorial!

I think this was scaling arbitrarily large before, yes. I suppose it’s plausible this is the first time the issue was noticed? But I’m pretty sure I’ve seen it scale arbitrarily large on a desktop device / full screen with normal (100%) DPI scaling.

Regardless, if this was intended behavior, then no need to fix anything since this issue is fixed by setting the ScaleType to crop. Just interesting that it scales down but not up.

I think this was scaling arbitrarily large before, yes. I suppose it’s plausible this is the first time the issue was noticed? But I’m pretty sure I’ve seen it scale arbitrarily large on a desktop device / full screen with normal (100%) DPI scaling.

OK, interesting, do you have an estimate of when you last saw this behavior? I checked our code and I don’t see any 9-slice changes since August 2022, so the current behavior shouldn’t have changed in the last year.

Regardless, if this was intended behavior, then no need to fix anything since this issue is fixed by setting the ScaleType to crop. Just interesting that it scales down but not up .

The reason that it scales down and not up is that 9-slice will scale the corner slices down if the ImageLabel is too small to contain the corner size. But if the ImageLabel is larger than the corner sizes, the corner slices remain constant size while the center region scales larger.

1 Like

Just when I reported this bug.

In that video you showed, the “5” square also scales up when the SliceCenter is set to something other than 0, 0, 0, 0. So wouldn’t if there are no corners, wouldn’t you expect the whole image to scale up?

Nevermind, I see. So this puts everything in section 9.

Okay, well you can close this issue.

1 Like