breaking map (warp3d)

httptests
UbitUmarov 2018-05-06 23:28:36 +01:00
parent b91c0f0d01
commit 00cc17c239
4 changed files with 38 additions and 39 deletions

View File

@ -30,6 +30,8 @@ using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.IO.Compression;
@ -3442,6 +3444,34 @@ namespace OpenSim.Framework
m_log.ErrorFormat("{0} Failed XML ({1} bytes) = {2}", message, length, xml);
}
/// <summary>
/// Performs a high quality image resize
/// </summary>
/// <param name="image">Image to resize</param>
/// <param name="width">New width</param>
/// <param name="height">New height</param>
/// <returns>Resized image</returns>
public static Bitmap ResizeImageSolid(Image image, int width, int height)
{
Bitmap result = new Bitmap(width, height, PixelFormat.Format24bppRgb);
using (ImageAttributes atrib = new ImageAttributes())
using (Graphics graphics = Graphics.FromImage(result))
{
atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
graphics.DrawImage(image,new Rectangle(0,0, result.Width, result.Height),
0, 0, image.Width, image.Height, GraphicsUnit.Pixel, atrib);
}
return result;
}
}
/* don't like this code
@ -3606,5 +3636,6 @@ namespace OpenSim.Framework
{
rng.GetBytes(buff);
}
}
}

View File

@ -161,7 +161,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
if(detailTexture[i].PixelFormat != PixelFormat.Format24bppRgb ||
detailTexture[i].Width != 16 || detailTexture[i].Height != 16)
using(Bitmap origBitmap = detailTexture[i])
detailTexture[i] = ImageUtils.ResizeImageSolid(origBitmap, 16, 16);
detailTexture[i] = Util.ResizeImageSolid(origBitmap, 16, 16);
// Save the decoded and resized texture to the cache
byte[] data;
@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
if(detailTexture[i].Width != 16 || detailTexture[i].Height != 16)
{
using(Bitmap origBitmap = detailTexture[i])
detailTexture[i] = ImageUtils.ResizeImageSolid(origBitmap, 16, 16);
detailTexture[i] = Util.ResizeImageSolid(origBitmap, 16, 16);
}
}
}

View File

@ -296,8 +296,8 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
int npointsx = (int)(regionsx / diff);
int npointsy = (int)(regionsy / diff);
float invsx = 1.0f / (npointsx);
float invsy = 1.0f / (npointsy);
float invsx = 1.0f / (npointsx * diff);
float invsy = 1.0f / (npointsy * diff);
npointsx++;
npointsy++;
@ -387,9 +387,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
texture = new warp_Texture(image);
warp_Material material = new warp_Material(texture);
// material.setReflectivity(50);
renderer.Scene.addMaterial("TerrainColor", material);
// renderer.Scene.material("TerrainColor").setReflectivity(0); // reduces tile seams a bit thanks lkalif
renderer.SetObjectMaterial("Terrain", "TerrainColor");
}
@ -775,32 +773,5 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
{
return Utils.Lerp(Utils.Lerp(v00, v01, xPercent), Utils.Lerp(v10, v11, xPercent), yPercent);
}
/// <summary>
/// Performs a high quality image resize
/// </summary>
/// <param name="image">Image to resize</param>
/// <param name="width">New width</param>
/// <param name="height">New height</param>
/// <returns>Resized image</returns>
public static Bitmap ResizeImageSolid(Image image, int width, int height)
{
Bitmap result = new Bitmap(width, height, PixelFormat.Format24bppRgb);
using (ImageAttributes atrib = new ImageAttributes())
using (Graphics graphics = Graphics.FromImage(result))
{
atrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.None;
graphics.DrawImage(image,new Rectangle(0,0, result.Width, result.Height),
0, 0, image.Width, image.Height, GraphicsUnit.Pixel, atrib);
}
return result;
}
}
}

View File

@ -1427,8 +1427,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
Bitmap mapTexture = new Bitmap(spanX, spanY);
ImageAttributes gatrib = new ImageAttributes();
Graphics g = Graphics.FromImage(mapTexture);
gatrib.SetWrapMode(System.Drawing.Drawing2D.WrapMode.TileFlipXY);
Graphics g = Graphics.FromImage(mapTexture);
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
@ -1687,11 +1688,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if(mb > Constants.RegionSize && mb > 0)
{
float scale = (float)Constants.RegionSize/(float)mb;
Size newsize = new Size();
newsize.Width = (int)(bx * scale);
newsize.Height = (int)(by * scale);
using(Bitmap scaledbmp = new Bitmap(mapbmp,newsize))
using(Bitmap scaledbmp = Util.ResizeImageSolid(mapbmp, (int)(bx * scale), (int)(by * scale)))
data = OpenJPEG.EncodeFromImage(scaledbmp, false);
}
else