mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
Fix black output from visplane explorer
This commit is contained in:
parent
f4e9556262
commit
db44d411c7
3 changed files with 20 additions and 35 deletions
|
@ -16,7 +16,9 @@
|
|||
|
||||
#region ================== Namespaces
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
|
||||
#endregion
|
||||
|
@ -34,6 +36,9 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Constructor
|
||||
public DynamicBitmapImage(Bitmap img, string name) : base(img, name)
|
||||
{
|
||||
if (img.PixelFormat != PixelFormat.Format32bppArgb)
|
||||
throw new Exception("Dynamic images must be in 32 bits ARGB format.");
|
||||
|
||||
// Initialize
|
||||
this.UseColorCorrection = false;
|
||||
this.dynamictexture = true;
|
||||
|
|
|
@ -402,9 +402,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
// Bitmap has incorrect format?
|
||||
if(bitmap.PixelFormat != PixelFormat.Format32bppArgb)
|
||||
{
|
||||
if(dynamictexture)
|
||||
throw new Exception("Dynamic images must be in 32 bits ARGB format.");
|
||||
|
||||
//General.ErrorLogger.Add(ErrorType.Warning, "Image '" + name + "' does not have A8R8G8B8 pixel format. Conversion was needed.");
|
||||
Bitmap oldbitmap = bitmap;
|
||||
try
|
||||
|
@ -467,12 +464,6 @@ namespace CodeImp.DoomBuilder.Data
|
|||
width = bitmap.Size.Width;
|
||||
height = bitmap.Size.Height;
|
||||
|
||||
if(dynamictexture)
|
||||
{
|
||||
if((width != General.NextPowerOf2(width)) || (height != General.NextPowerOf2(height)))
|
||||
throw new Exception("Dynamic images must have a size in powers of 2.");
|
||||
}
|
||||
|
||||
// Do we still have to set a scale?
|
||||
if((scale.x == 0.0f) && (scale.y == 0.0f))
|
||||
{
|
||||
|
@ -688,16 +679,8 @@ namespace CodeImp.DoomBuilder.Data
|
|||
|
||||
texture = new Texture(General.Map.Graphics, loadedbitmap);
|
||||
|
||||
if (dynamictexture)
|
||||
{
|
||||
if ((width != texture.Width) || (height != texture.Height))
|
||||
throw new Exception("Could not create a texture with the same size as the image.");
|
||||
}
|
||||
else
|
||||
{
|
||||
loadedbitmap.Dispose();
|
||||
loadedbitmap = null;
|
||||
}
|
||||
loadedbitmap.Dispose();
|
||||
loadedbitmap = null;
|
||||
|
||||
#if DEBUG
|
||||
texture.Tag = name; //mxd. Helps with tracking undisposed resources...
|
||||
|
@ -706,15 +689,14 @@ namespace CodeImp.DoomBuilder.Data
|
|||
}
|
||||
|
||||
// This updates a dynamic texture
|
||||
public void UpdateTexture()
|
||||
public void UpdateTexture(Bitmap canvas)
|
||||
{
|
||||
if (canvas.PixelFormat != PixelFormat.Format32bppArgb)
|
||||
throw new Exception("Dynamic images must be in 32 bits ARGB format.");
|
||||
if(!dynamictexture)
|
||||
throw new Exception("The image must be a dynamic image to support direct updating.");
|
||||
|
||||
if((texture != null) && !texture.Disposed)
|
||||
{
|
||||
General.Map.Graphics.SetPixels(texture, loadedbitmap);
|
||||
}
|
||||
General.Map.Graphics.SetPixels(GetTexture(), canvas);
|
||||
}
|
||||
|
||||
// This destroys the Direct3D texture
|
||||
|
|
|
@ -29,13 +29,6 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
AllowCopyPaste = false)]
|
||||
public class VisplaneExplorerMode : ClassicMode
|
||||
{
|
||||
#region ================== APIs
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern void RtlZeroMemory(IntPtr dst, int length);
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// The image is the ImageData resource for Doom Builder to work with
|
||||
|
@ -119,8 +112,13 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
Palette pal = (BuilderPlug.InterfaceForm.ShowHeatmap ? BuilderPlug.Palettes[(int)ViewStats.Heatmap] : BuilderPlug.Palettes[viewstats]);
|
||||
|
||||
BitmapData bd = canvas.LockBits(new Rectangle(0, 0, canvas.Size.Width, canvas.Size.Height), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);
|
||||
RtlZeroMemory(bd.Scan0, bd.Width * bd.Height * 4);
|
||||
int* p = (int*)bd.Scan0.ToPointer();
|
||||
uint* p = (uint*)bd.Scan0.ToPointer();
|
||||
|
||||
int count = bd.Width * bd.Height;
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
p[i] = 0;
|
||||
}
|
||||
|
||||
foreach(KeyValuePair<Point, Tile> t in tiles)
|
||||
{
|
||||
|
@ -168,13 +166,13 @@ namespace CodeImp.DoomBuilder.Plugins.VisplaneExplorer
|
|||
|
||||
// Get the data and apply the color
|
||||
byte value = t.Value.GetPointByte((int)ux, Tile.TILE_SIZE - 1 - (int)uy, viewstats);
|
||||
p[screeny * bd.Width + screenx] = pal.Colors[value];
|
||||
p[screeny * bd.Width + screenx] = (uint)pal.Colors[value];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
canvas.UnlockBits(bd);
|
||||
image.UpdateTexture();
|
||||
image.UpdateTexture(canvas);
|
||||
}
|
||||
|
||||
// This queues points for all current tiles
|
||||
|
|
Loading…
Reference in a new issue