Skip to content
Snippets Groups Projects
Commit 898fe21f authored by biwa's avatar biwa
Browse files

TEXTURES lump: fixed a problem where textures that use textures as patches...

TEXTURES lump: fixed a problem where textures that use textures as patches were too bright when gamma correction was enabled
parent 0d78a48b
No related branches found
No related tags found
No related merge requests found
...@@ -235,42 +235,44 @@ namespace CodeImp.DoomBuilder.Data ...@@ -235,42 +235,44 @@ namespace CodeImp.DoomBuilder.Data
public Image GetBackgroundBitmap() public Image GetBackgroundBitmap()
{ {
return LocalGetBitmap(); return LocalGetBitmap(usecolorcorrection);
} }
public Bitmap GetSkyboxBitmap() public Bitmap GetSkyboxBitmap()
{ {
return LocalGetBitmap(); return LocalGetBitmap(usecolorcorrection);
} }
public Bitmap ExportBitmap() public Bitmap ExportBitmap()
{ {
return LocalGetBitmap(); return LocalGetBitmap(usecolorcorrection);
} }
public Bitmap GetSpritePreview() public Bitmap GetSpritePreview()
{ {
if (spritepreviewbitmap == null) if (spritepreviewbitmap == null)
spritepreviewbitmap = LocalGetBitmap(); spritepreviewbitmap = LocalGetBitmap(usecolorcorrection);
return spritepreviewbitmap; return spritepreviewbitmap;
} }
// Loads the image directly. This is needed by the background loader for some patches. // Loads the image directly. This is needed by the background loader for some patches.
public Bitmap LocalGetBitmap() // biwa. Just setting UseGammeCorrection before LocalGetBitmap was not enough, since its
{ // state is subject to race conditions at load time when using a texture as a patch
// Note: if this turns out to be too slow, do NOT try to make it use GetBitmap or bitmap. public Bitmap LocalGetBitmap(bool withcolorcorrection)
// Create a cache for the local background loader thread instead. {
// Note: if this turns out to be too slow, do NOT try to make it use GetBitmap or bitmap.
// Create a cache for the local background loader thread instead.
LocalLoadResult result = LocalLoadImage(); LocalLoadResult result = LocalLoadImage();
if (result.messages.Any(x => x.Type == ErrorType.Error)) if (result.messages.Any(x => x.Type == ErrorType.Error))
{ {
return Properties.Resources.Failed; return Properties.Resources.Failed;
} }
ConvertImageFormat(result); ConvertImageFormat(result, withcolorcorrection);
return result.bitmap; return result.bitmap;
} }
public void LoadImageNow() public void LoadImageNow()
{ {
if (imagestate != ImageLoadState.Ready) if (imagestate != ImageLoadState.Ready)
{ {
...@@ -293,7 +295,7 @@ namespace CodeImp.DoomBuilder.Data ...@@ -293,7 +295,7 @@ namespace CodeImp.DoomBuilder.Data
// Do the loading // Do the loading
LocalLoadResult loadResult = LocalLoadImage(); LocalLoadResult loadResult = LocalLoadImage();
ConvertImageFormat(loadResult); ConvertImageFormat(loadResult, usecolorcorrection);
MakeImagePreview(loadResult); MakeImagePreview(loadResult);
MakeAlphaTestImage(loadResult); MakeAlphaTestImage(loadResult);
...@@ -393,7 +395,7 @@ namespace CodeImp.DoomBuilder.Data ...@@ -393,7 +395,7 @@ namespace CodeImp.DoomBuilder.Data
public string Text { get; set; } public string Text { get; set; }
} }
void ConvertImageFormat(LocalLoadResult loadResult) void ConvertImageFormat(LocalLoadResult loadResult, bool withcolorcorrection)
{ {
// Bitmap loaded successfully? // Bitmap loaded successfully?
Bitmap bitmap = loadResult.bitmap; Bitmap bitmap = loadResult.bitmap;
...@@ -427,7 +429,7 @@ namespace CodeImp.DoomBuilder.Data ...@@ -427,7 +429,7 @@ namespace CodeImp.DoomBuilder.Data
} }
// This applies brightness correction on the image // This applies brightness correction on the image
if(usecolorcorrection) if(withcolorcorrection)
{ {
BitmapData bmpdata = null; BitmapData bmpdata = null;
......
...@@ -202,9 +202,11 @@ namespace CodeImp.DoomBuilder.Data ...@@ -202,9 +202,11 @@ namespace CodeImp.DoomBuilder.Data
ImageData img = General.Map.Data.GetTextureImage(p.LumpName); ImageData img = General.Map.Data.GetTextureImage(p.LumpName);
if(!(img is UnknownImage) && img != this) if(!(img is UnknownImage) && img != this)
{ {
//mxd. Apply transformations from TexturePatch. We don't want to modify the original bitmap here, so make a copy //mxd. Apply transformations from TexturePatch. We don't want to modify the original bitmap here, so make a copy
Bitmap bmp = new Bitmap(img.LocalGetBitmap()); // biwa. Make sure to get the image without color correction, as the final texture would be too bright if the patch
Bitmap patchbmp = TransformPatch(bitmap, p, bmp); // is also a texture
Bitmap bmp = new Bitmap(img.LocalGetBitmap(false));
Bitmap patchbmp = TransformPatch(bitmap, p, bmp);
// Draw the patch on the texture image // Draw the patch on the texture image
Rectangle tgtrect = new Rectangle(p.X, p.Y, patchbmp.Size.Width, patchbmp.Size.Height); Rectangle tgtrect = new Rectangle(p.X, p.Y, patchbmp.Size.Width, patchbmp.Size.Height);
......
...@@ -260,9 +260,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO ...@@ -260,9 +260,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
// The image might have a color correction applied, but we need it without. So we use LocalGetBitmap, because it reloads the image, // The image might have a color correction applied, but we need it without. So we use LocalGetBitmap, because it reloads the image,
// but doesn't applie the color correction if we set UseColorCorrection to false first // but doesn't applie the color correction if we set UseColorCorrection to false first
ImageData imagedata = General.Map.Data.GetFlatImage(s.FloorTexture); ImageData imagedata = General.Map.Data.GetFlatImage(s.FloorTexture);
imagedata.UseColorCorrection = false; brushtexture = new Bitmap(imagedata.LocalGetBitmap(false));
brushtexture = new Bitmap(imagedata.LocalGetBitmap());
imagedata.UseColorCorrection = true;
textureoffset.x = s.Fields.GetValue("xpanningfloor", 0.0) * scale; textureoffset.x = s.Fields.GetValue("xpanningfloor", 0.0) * scale;
textureoffset.y = s.Fields.GetValue("ypanningfloor", 0.0) * scale; textureoffset.y = s.Fields.GetValue("ypanningfloor", 0.0) * scale;
...@@ -276,9 +274,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO ...@@ -276,9 +274,7 @@ namespace CodeImp.DoomBuilder.BuilderModes.IO
// The image might have a color correction applied, but we need it without. So we use LocalGetBitmap, because it reloads the image, // The image might have a color correction applied, but we need it without. So we use LocalGetBitmap, because it reloads the image,
// but doesn't applie the color correction if we set UseColorCorrection to false first // but doesn't applie the color correction if we set UseColorCorrection to false first
ImageData imagedata = General.Map.Data.GetFlatImage(s.CeilTexture); ImageData imagedata = General.Map.Data.GetFlatImage(s.CeilTexture);
imagedata.UseColorCorrection = false; brushtexture = new Bitmap(imagedata.LocalGetBitmap(false));
brushtexture = new Bitmap(imagedata.LocalGetBitmap());
imagedata.UseColorCorrection = true;
textureoffset.x = s.Fields.GetValue("xpanningceiling", 0.0) * scale; textureoffset.x = s.Fields.GetValue("xpanningceiling", 0.0) * scale;
textureoffset.y = s.Fields.GetValue("ypanningceiling", 0.0) * scale; textureoffset.y = s.Fields.GetValue("ypanningceiling", 0.0) * scale;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment