-
-
Notifications
You must be signed in to change notification settings - Fork 95
Description
Description
I'm encountering an image scaling issue with the cogentcore framework.
I'm using a 1920x1080 image as a background, but it remains at its original size and doesn't scale to fit larger displays. Specifically, when running on a 2K (2560x1440) monitor, the image stays at 1920x1080 resolution instead of scaling up to match the display's higher resolution.
Expected Behavior
The 1920x1080 image should scale to fill the entire window on 2K (2560x1440) displays, maintaining appropriate aspect ratio while covering available space.
Actual Behavior
The image stays at its original 1920x1080 resolution and does not scale to fit the 2K display, leaving empty space around it.
Environment
- Image resolution: 1920x1080
- Display resolution: 2K (2560x1440)
Is there an issue with the image scaling implementation here? Could I be missing styling properties needed for proper scaling behavior on higher resolution displays like 2K?
How to reproduce
- Use a 2K (2560x1440) display
- Run the provided code with a 1920x1080 image set as background
- Observe that the image remains at its original size (1920x1080) instead of scaling to fill the 2K display area
Example code
package main
import (
"cogentcore.org/core/base/iox/imagex"
"cogentcore.org/core/core"
"cogentcore.org/core/styles"
"cogentcore.org/core/styles/units"
)
func main() {
b := core.NewBody()
img, _, _ := imagex.Open("E:\\goygopro\\textures\\bg_menu.jpg")
b.Scene.Styler(func(s *styles.Style) {
s.Padding.SetAll(units.Dp(0))
})
b.Styler(func(s *styles.Style) {
s.Background = img
s.ObjectFit = styles.FitFill
s.Justify.Content = styles.Center
s.Align.Content = styles.Center
})
b.RunMainWindow()
}
Platform
Windows
Metadata
Metadata
Assignees
Labels
Type
Projects
Status