Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageCropper is not able to work with BitmapImage. #617

Open
2 of 24 tasks
hexawyz opened this issue Feb 1, 2025 · 0 comments
Open
2 of 24 tasks

ImageCropper is not able to work with BitmapImage. #617

hexawyz opened this issue Feb 1, 2025 · 0 comments

Comments

@hexawyz
Copy link

hexawyz commented Feb 1, 2025

Describe the bug

Trying to work with ImageCropper to generate a cropping region, I am forced to use WriteableBitmap.
While I understand that some parts of the components will want to work with a WriteableBitmap, but that is not the case for the core UI function of selecting a cropping zone.
This prevents for example, one from using BitmapImages which support animated images.
It should be perfectly reasonable to allow users to use the component only for its UI presentation features, and implement the cropping themselves if they desire to.

Steps to reproduce

Try loading an animated image into the ImageCropper. It will only show the first frame.
Setting a BitmapImage loaded externally as the source is not possible.

Expected behavior

ImageCropper should accept any BitmapSource as an input (as it contains the properties PixelWidth and PixelHeight that are used everywhere).
ImageCropper should throw an exception if methods that require the Source to be a WriteableBitmap are called when the Source is of a different type.

Screenshots

No response

Code Platform

  • UWP
  • WinAppSDK / WinUI 3
  • Web Assembly (WASM)
  • Android
  • iOS
  • MacOS
  • Linux / GTK

Windows Build Number

  • Windows 10 1809 (Build 17763)
  • Windows 10 1903 (Build 18362)
  • Windows 10 1909 (Build 18363)
  • Windows 10 2004 (Build 19041)
  • Windows 10 20H2 (Build 19042)
  • Windows 10 21H1 (Build 19043)
  • Windows 10 21H2 (Build 19044)
  • Windows 10 22H2 (Build 19045)
  • Windows 11 21H2 (Build 22000)
  • Other (specify)

Other Windows Build number

No response

App minimum and target SDK version

  • Windows 10, version 1809 (Build 17763)
  • Windows 10, version 1903 (Build 18362)
  • Windows 10, version 1909 (Build 18363)
  • Windows 10, version 2004 (Build 19041)
  • Windows 10, version 2104 (Build 20348)
  • Windows 11, version 22H2 (Build 22000)
  • Other (specify)

Other SDK version

10.0.22621.48

Visual Studio Version

2022

Visual Studio Build Number

No response

Device form factor

Desktop

Additional context

AFAIK, the only part that actually requires the source to be a WriteableBitmap is https://github.com/CommunityToolkit/Windows/blob/main/components/ImageCropper/src/ImageCropper.Helpers.cs

The ImageCropper should accept images that are loaded asynchronously, as a BitmapSource is not guaranteed to have dimensions until the image is actually loaded. It is already a problem on the current implementation using WriteableBitmap. (If one is creating a 1x1 bitmap before asynchronously loading the image, ImageCropper will reject it)
This can be addressed by listening for changes to PixelWidth and PixelHeight properties instead of rejecting the Source. (using RegisterPropertyChangedCallback
In case any of those properties are not valid, it should be possible for the ImageCropper to simply consider the image as not being assigned, which will make it work more gracefully in different scenarios.

Help us help you

Yes, I'd like to be assigned to work on this item.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant