From 910b3da266d6c47e9c126f82bf31bd0db237b157 Mon Sep 17 00:00:00 2001 From: Nathan Letwory Date: Tue, 9 Aug 2016 11:29:12 +0300 Subject: [PATCH] Put wallpaper through linear workflow. Without this wallpapers could turn up with wrong gamma applied. #RH-34959 Needs Testing #RH-34959 Assigned to: brianjames #RH-34959 add Worked on By nathan --- Converters/BitmapConverter.cs | 4 ++-- CyclesBackground.cs | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Converters/BitmapConverter.cs b/Converters/BitmapConverter.cs index 53861fb1..7e5b0796 100644 --- a/Converters/BitmapConverter.cs +++ b/Converters/BitmapConverter.cs @@ -253,7 +253,7 @@ public static void EnvironmentBitmapFromEvaluator(RenderEnvironment rm, CyclesTe } } - public static byte[] ReadByteBitmapFromBitmap(int pwidth, int pheight, Bitmap bm) + public static ByteBitmap ReadByteBitmapFromBitmap(uint id, int pwidth, int pheight, Bitmap bm) { var upixel = new byte[pwidth * pheight * 4]; @@ -269,7 +269,7 @@ public static byte[] ReadByteBitmapFromBitmap(int pwidth, int pheight, Bitmap bm upixel[offset + 3] = px.A; } } - return upixel; + return new ByteBitmap(id, upixel, pwidth, pheight); } private static byte[] ReadByteBitmapFromEvaluator(int pwidth, int pheight, TextureEvaluator textureEvaluator, bool isEnvironment, bool planarProjection) diff --git a/CyclesBackground.cs b/CyclesBackground.cs index 1f258bdb..f5401e9a 100644 --- a/CyclesBackground.cs +++ b/CyclesBackground.cs @@ -158,9 +158,8 @@ public void HandleWallpaper(ViewInfo view, bool scaleToFit) wallpaper.Clear(); return; } - m_old_wallpaper = view.WallpaperFilename != null ? view.WallpaperFilename : ""; - + var crc = Rhino.RhinoMath.CRC32(27, System.Text.Encoding.UTF8.GetBytes(m_old_wallpaper)); try { int near, far; @@ -238,7 +237,10 @@ public void HandleWallpaper(ViewInfo view, bool scaleToFit) var tmpf = string.Format("{0}\\{1}.png", Environment.GetEnvironmentVariable("TEMP"), "RC_wallpaper"); newBitmap.Save(tmpf, ImageFormat.Png); #endif - wallpaper.TexByte = BitmapConverter.ReadByteBitmapFromBitmap(newBitmap.Size.Width, newBitmap.Size.Height, newBitmap); + var wallpaperbm = BitmapConverter.ReadByteBitmapFromBitmap(crc, newBitmap.Size.Width, newBitmap.Size.Height, newBitmap); + wallpaperbm.ApplyGamma(gamma); + wallpaper.TexByte = wallpaperbm.corrected; + wallpaperbm.SaveBitmaps(); wallpaper.TexWidth = newBitmap.Width; wallpaper.TexHeight = newBitmap.Height; wallpaper.Name = string.Format("{0}_{1}x{2}_{3}_{4}_{5}_{6}",