-
Notifications
You must be signed in to change notification settings - Fork 22
Fix Image Gamma Unsupported By glTF #138
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,6 +30,28 @@ public static (string, ImageFormat) GetMimeType(string path) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// <summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Removes non-default gamma or ICC profile metadata from a PNG/JPG file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// by re-encoding it to a clean sRGB version in memory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// </summary> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// <param name="path">Path to the source image</param> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// <returns>Byte array of the cleaned image (PNG)</returns> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static byte[] CleanGamma(string path, ImageFormat imageFormat) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using (var original = new Bitmap(path)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using (var ms = new MemoryStream()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Convert to standard sRGB (System.Drawing assumes sRGB by default) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using (var converted = new Bitmap(original.Width, original.Height, PixelFormat.Format24bppRgb)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| using (var g = Graphics.FromImage(converted)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| g.DrawImage(original, 0, 0, original.Width, original.Height); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| converted.Save(ms, imageFormat); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ms.ToArray(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+39
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Alpha channel is lost when using Format24bppRgb. The method uses Apply this diff to preserve alpha: - using (var converted = new Bitmap(original.Width, original.Height, PixelFormat.Format24bppRgb))
+ using (var converted = new Bitmap(original.Width, original.Height, PixelFormat.Format32bppArgb))📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| public static byte[] BlendImageWithColor( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| byte[] imageBytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| double fade, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update documentation to reflect parameterized format.
The documentation states "Byte array of the cleaned image (PNG)" but the method returns the format specified by the
imageFormatparameter, which could be JPEG, BMP, or GIF.Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents