diff --git a/SLImageUpload/frmSLImageUpload.cs b/SLImageUpload/frmSLImageUpload.cs index ed20d638..3ed5a9bf 100644 --- a/SLImageUpload/frmSLImageUpload.cs +++ b/SLImageUpload/frmSLImageUpload.cs @@ -87,7 +87,7 @@ namespace SLImageUpload { if (lowfilename.EndsWith(".jp2") || lowfilename.EndsWith(".j2c")) { - libsecondlife.Image imgData; + ManagedImage imgData; // Upload JPEG2000 images untouched UploadData = System.IO.File.ReadAllBytes(FileName); diff --git a/libsecondlife/AssetTypes.cs b/libsecondlife/AssetTypes.cs index 10d119cf..fa85aac3 100644 --- a/libsecondlife/AssetTypes.cs +++ b/libsecondlife/AssetTypes.cs @@ -216,13 +216,13 @@ namespace libsecondlife { public override AssetType AssetType { get { return AssetType.Texture; } } - public Image Image; + public ManagedImage Image; public AssetTexture() { } public AssetTexture(byte[] assetData) : base(assetData) { } - public AssetTexture(Image image) + public AssetTexture(ManagedImage image) { Image = image; } diff --git a/libsecondlife/BakeLayer.cs b/libsecondlife/BakeLayer.cs index cb954087..b4bb6b78 100644 --- a/libsecondlife/BakeLayer.cs +++ b/libsecondlife/BakeLayer.cs @@ -171,7 +171,7 @@ namespace libsecondlife.Baking protected void Bake() { - _bakedTexture = new AssetTexture(new Image(_bakeWidth, _bakeHeight, ImageChannels.Color | ImageChannels.Alpha | ImageChannels.Bump)); + _bakedTexture = new AssetTexture(new ManagedImage(_bakeWidth, _bakeHeight, ImageChannels.Color | ImageChannels.Alpha | ImageChannels.Bump)); if (_bakeType == AppearanceManager.BakeType.Eyes) { @@ -232,14 +232,12 @@ namespace libsecondlife.Baking private bool DrawLayer(AppearanceManager.TextureIndex textureIndex) { - int i = 0; AssetTexture texture; - - Image source; - + ManagedImage source; bool sourceHasAlpha; bool sourceHasBump; bool copySourceAlphaToBakedLayer; + int i = 0; try { diff --git a/libsecondlife/Image.cs b/libsecondlife/Image.cs index 090783ff..93a84b00 100644 --- a/libsecondlife/Image.cs +++ b/libsecondlife/Image.cs @@ -42,7 +42,7 @@ namespace libsecondlife NearestNeighbor } - public class Image + public class ManagedImage { /// /// Image width @@ -90,7 +90,7 @@ namespace libsecondlife /// width /// height /// channel flags - public Image(int width, int height, ImageChannels channels) + public ManagedImage(int width, int height, ImageChannels channels) { Width = width; Height = height; @@ -121,7 +121,7 @@ namespace libsecondlife /// /// /// - public Image(System.Drawing.Bitmap bitmap) + public ManagedImage(System.Drawing.Bitmap bitmap) { Width = bitmap.Width; Height = bitmap.Height; @@ -363,9 +363,9 @@ namespace libsecondlife Fill(Bump, 0); } - public Image Clone() + public ManagedImage Clone() { - Image image = new Image(Width, Height, Channels); + ManagedImage image = new ManagedImage(Width, Height, Channels); if (Red != null) image.Red = (byte[])Red.Clone(); if (Green != null) image.Green = (byte[])Green.Clone(); if (Blue != null) image.Blue = (byte[])Blue.Clone(); diff --git a/libsecondlife/InventoryManager.cs b/libsecondlife/InventoryManager.cs index 48bfeeb2..4e48a958 100644 --- a/libsecondlife/InventoryManager.cs +++ b/libsecondlife/InventoryManager.cs @@ -299,7 +299,7 @@ namespace libsecondlife /// /// InventoryTexture Class representing a graphical image /// - /// + /// public class InventoryTexture : InventoryItem { /// diff --git a/libsecondlife/OpenJPEG.cs b/libsecondlife/OpenJPEG.cs index ef8fdc00..e94f5d0a 100644 --- a/libsecondlife/OpenJPEG.cs +++ b/libsecondlife/OpenJPEG.cs @@ -75,12 +75,12 @@ namespace OpenJPEGNet private static extern bool LibslDecode(ref MarshalledImage image); /// - /// Encode a object into a byte array + /// Encode a object into a byte array /// - /// The object to encode + /// The object to encode /// true to enable lossless conversion, only useful for small images ie: sculptmaps /// A byte array containing the encoded Image object - public static byte[] Encode(libsecondlife.Image image, bool lossless) + public static byte[] Encode(ManagedImage image, bool lossless) { if ( (image.Channels & ImageChannels.Color) == 0 || @@ -126,21 +126,21 @@ namespace OpenJPEGNet } /// - /// Encode a object into a byte array + /// Encode a object into a byte array /// - /// The object to encode + /// The object to encode /// a byte array of the encoded image - public static byte[] Encode(libsecondlife.Image image) + public static byte[] Encode(ManagedImage image) { return Encode(image, false); } /// - /// Decode a object from a byte array + /// Decode a object from a byte array /// /// The encoded byte array to decode - /// A object - public static libsecondlife.Image Decode(byte[] encoded) + /// A object + public static ManagedImage Decode(byte[] encoded) { MarshalledImage marshalled = new MarshalledImage(); @@ -152,20 +152,20 @@ namespace OpenJPEGNet // codec will allocate output buffer LibslDecode(ref marshalled); - libsecondlife.Image image; + ManagedImage image; int n = marshalled.width * marshalled.height; switch (marshalled.components) { case 1: // grayscale - image = new libsecondlife.Image(marshalled.width, marshalled.height, ImageChannels.Color); + image = new ManagedImage(marshalled.width, marshalled.height, ImageChannels.Color); Marshal.Copy(marshalled.decoded, image.Red, 0, n); Array.Copy(image.Red, image.Green, n); Array.Copy(image.Red, image.Blue, n); break; case 2: // grayscale + alpha - image = new libsecondlife.Image(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha); + image = new ManagedImage(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha); Marshal.Copy(marshalled.decoded, image.Red, 0, n); Array.Copy(image.Red, image.Green, n); Array.Copy(image.Red, image.Blue, n); @@ -173,14 +173,14 @@ namespace OpenJPEGNet break; case 3: // RGB - image = new libsecondlife.Image(marshalled.width, marshalled.height, ImageChannels.Color); + image = new ManagedImage(marshalled.width, marshalled.height, ImageChannels.Color); Marshal.Copy(marshalled.decoded, image.Red, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n), image.Green, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n * 2), image.Blue, 0, n); break; case 4: // RGBA - image = new libsecondlife.Image(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha); + image = new ManagedImage(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha); Marshal.Copy(marshalled.decoded, image.Red, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n), image.Green, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n * 2), image.Blue, 0, n); @@ -188,7 +188,7 @@ namespace OpenJPEGNet break; case 5: // RGBBA - image = new libsecondlife.Image(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha | ImageChannels.Bump); + image = new ManagedImage(marshalled.width, marshalled.height, ImageChannels.Color | ImageChannels.Alpha | ImageChannels.Bump); Marshal.Copy(marshalled.decoded, image.Red, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n), image.Green, 0, n); Marshal.Copy((IntPtr)(marshalled.decoded.ToInt64() + n * 2), image.Blue, 0, n); @@ -212,12 +212,12 @@ namespace OpenJPEGNet public const int TGA_HEADER_SIZE = 32; /// - /// Decode an encoded byte array to a TGA byte array + /// Decode an encoded byte array to a TGA byte array /// /// The encoded image - /// A object + /// A object /// A TGA decoded byte array containing the encoded image - public static byte[] DecodeToTGA(byte[] encoded, out libsecondlife.Image image) + public static byte[] DecodeToTGA(byte[] encoded, out ManagedImage image) { image = Decode(encoded); return image.ExportTGA(); @@ -228,9 +228,9 @@ namespace OpenJPEGNet /// directly in Windows Forms or by the System.Drawing.Image class /// /// A encoded byte array containing the source image to decode - /// A object + /// A object /// A object - public static System.Drawing.Image DecodeToImage(byte[] encoded, out libsecondlife.Image image) + public static System.Drawing.Image DecodeToImage(byte[] encoded, out ManagedImage image) { return LoadTGAClass.LoadTGA(new MemoryStream(DecodeToTGA(encoded, out image))); } @@ -244,7 +244,7 @@ namespace OpenJPEGNet public unsafe static byte[] EncodeFromImage(Bitmap bitmap, bool lossless) { BitmapData bd; - libsecondlife.Image decoded; + ManagedImage decoded; int bitmapWidth = bitmap.Width; int bitmapHeight = bitmap.Height; @@ -254,7 +254,7 @@ namespace OpenJPEGNet if ((bitmap.PixelFormat & PixelFormat.Alpha) != 0 || (bitmap.PixelFormat & PixelFormat.PAlpha) != 0) { // four layers, RGBA - decoded = new libsecondlife.Image(bitmapWidth, bitmapHeight, ImageChannels.Color | ImageChannels.Alpha); + decoded = new ManagedImage(bitmapWidth, bitmapHeight, ImageChannels.Color | ImageChannels.Alpha); bd = bitmap.LockBits(new Rectangle(0, 0, bitmapWidth, bitmapHeight), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb); byte* pixel = (byte*)bd.Scan0; @@ -270,7 +270,7 @@ namespace OpenJPEGNet else if (bitmap.PixelFormat == PixelFormat.Format16bppGrayScale) { // one layer - decoded = new libsecondlife.Image(bitmapWidth, bitmapHeight, ImageChannels.Color); + decoded = new ManagedImage(bitmapWidth, bitmapHeight, ImageChannels.Color); bd = bitmap.LockBits(new Rectangle(0, 0, bitmapWidth, bitmapHeight), ImageLockMode.ReadOnly, PixelFormat.Format16bppGrayScale); byte* pixel = (byte*)bd.Scan0; @@ -289,7 +289,7 @@ namespace OpenJPEGNet else { // three layers, RGB - decoded = new libsecondlife.Image(bitmapWidth, bitmapHeight, ImageChannels.Color); + decoded = new ManagedImage(bitmapWidth, bitmapHeight, ImageChannels.Color); bd = bitmap.LockBits(new Rectangle(0, 0, bitmapWidth, bitmapHeight), ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb); byte* pixel = (byte*)bd.Scan0; diff --git a/libsecondlife/TGALoader.cs b/libsecondlife/TGALoader.cs index 85cfb7fe..f7b6dd6e 100644 --- a/libsecondlife/TGALoader.cs +++ b/libsecondlife/TGALoader.cs @@ -25,6 +25,7 @@ */ using System; +using libsecondlife; namespace OpenJPEGNet { @@ -492,12 +493,12 @@ namespace OpenJPEGNet return b; } - public static unsafe libsecondlife.Image LoadTGAImage(System.IO.Stream source) + public static unsafe ManagedImage LoadTGAImage(System.IO.Stream source) { return LoadTGAImage(source, false); } - public static unsafe libsecondlife.Image LoadTGAImage(System.IO.Stream source, bool mask) + public static unsafe ManagedImage LoadTGAImage(System.IO.Stream source, bool mask) { byte[] buffer = new byte[source.Length]; source.Read(buffer, 0, buffer.Length); @@ -559,11 +560,11 @@ namespace OpenJPEGNet } int n = header.ImageSpec.Width * header.ImageSpec.Height; - libsecondlife.Image image; + ManagedImage image; if (mask && header.ImageSpec.AlphaBits == 0 && header.ImageSpec.PixelDepth == 8) { - image = new libsecondlife.Image(header.ImageSpec.Width, header.ImageSpec.Height, libsecondlife.ImageChannels.Alpha); + image = new ManagedImage(header.ImageSpec.Width, header.ImageSpec.Height, ImageChannels.Alpha); int p = 3; for (int i = 0; i < n; i++) @@ -574,7 +575,7 @@ namespace OpenJPEGNet } else { - image = new libsecondlife.Image(header.ImageSpec.Width, header.ImageSpec.Height, libsecondlife.ImageChannels.Color | libsecondlife.ImageChannels.Alpha); + image = new ManagedImage(header.ImageSpec.Width, header.ImageSpec.Height, ImageChannels.Color | ImageChannels.Alpha); int p = 0; for (int i = 0; i < n; i++) diff --git a/libsecondlife/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs b/libsecondlife/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs index de314065..d943fc02 100644 --- a/libsecondlife/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/Inventory/DumpOutfitCommand.cs @@ -96,7 +96,7 @@ namespace libsecondlife.TestClient File.WriteAllBytes(image.ID.ToString() + ".jp2", image.AssetData); Console.WriteLine("Wrote JPEG2000 image " + image.ID.ToString() + ".jp2"); - libsecondlife.Image imgData; + ManagedImage imgData; byte[] tgaFile = OpenJPEGNet.OpenJPEG.DecodeToTGA(image.AssetData, out imgData); File.WriteAllBytes(image.ID.ToString() + ".tga", tgaFile); Console.WriteLine("Wrote TGA image " + image.ID.ToString() + ".tga"); diff --git a/libsecondlife/examples/TestClient/Commands/Inventory/UploadImageCommand.cs b/libsecondlife/examples/TestClient/Commands/Inventory/UploadImageCommand.cs index 87acb1a7..48ee09a2 100644 --- a/libsecondlife/examples/TestClient/Commands/Inventory/UploadImageCommand.cs +++ b/libsecondlife/examples/TestClient/Commands/Inventory/UploadImageCommand.cs @@ -93,7 +93,7 @@ namespace libsecondlife.TestClient { if (lowfilename.EndsWith(".jp2") || lowfilename.EndsWith(".j2c")) { - libsecondlife.Image imgData; + ManagedImage imgData; // Upload JPEG2000 images untouched UploadData = System.IO.File.ReadAllBytes(fileName); diff --git a/libsecondlife/examples/groupmanager/frmGroupInfo.cs b/libsecondlife/examples/groupmanager/frmGroupInfo.cs index 2f8e9a14..19341470 100644 --- a/libsecondlife/examples/groupmanager/frmGroupInfo.cs +++ b/libsecondlife/examples/groupmanager/frmGroupInfo.cs @@ -80,7 +80,7 @@ namespace groupmanager void Assets_OnImageReceived(ImageDownload image, AssetTexture assetTexture) { - libsecondlife.Image imgData; + ManagedImage imgData; if (image.Success) picInsignia.Image = OpenJPEGNet.OpenJPEG.DecodeToImage(image.AssetData, out imgData);