本文整理汇总了C#中TexImage类的典型用法代码示例。如果您正苦于以下问题:C# TexImage类的具体用法?C# TexImage怎么用?C# TexImage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TexImage类属于命名空间,在下文中一共展示了TexImage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateArrayTest
public void CreateArrayTest(string file1, string file2)
{
var list = new List<TexImage>();
for (int i = 0; i < 5; ++i)
{
var temp = new TexImage();
fiLib.Execute(temp, new LoadingRequest(file1, false));
list.Add(temp);
temp = new TexImage();
fiLib.Execute(temp, new LoadingRequest(file2, false));
list.Add(temp);
}
var array = new TexImage();
library.Execute(array, new ArrayCreationRequest(list));
Assert.IsTrue(array.ArraySize == list.Count);
//Console.WriteLine("ArrayTexLibrary_CreateArray_" + Path.GetFileName(file1) + "_" + Path.GetFileName(file2) + "." + TestTools.ComputeSHA1(array.Data, array.DataSize));
Assert.IsTrue(TestTools.ComputeSHA1(array.Data, array.DataSize).Equals(TestTools.GetInstance().Checksum["ArrayTexLibrary_CreateArray_" + Path.GetFileName(file1) + "_" + Path.GetFileName(file2)]));
array.Dispose();
foreach (var image in list)
{
image.Dispose();
}
}
示例2: Execute
public void Execute(TexImage image, IRequest request)
{
switch (request.Type)
{
case RequestType.ArrayCreation:
CreateArray(image, (ArrayCreationRequest)request);
break;
case RequestType.ArrayExtraction:
Extract(image, (ArrayExtractionRequest)request);
break;
case RequestType.ArrayUpdate:
Update(image, (ArrayUpdateRequest)request);
break;
case RequestType.ArrayInsertion:
Insert(image, (ArrayInsertionRequest)request);
break;
case RequestType.ArrayElementRemoval:
Remove(image, (ArrayElementRemovalRequest)request);
break;
case RequestType.CubeCreation:
CreateCube(image, (CubeCreationRequest)request);
break;
default:
Log.Error("ArrayTexLib can't handle this request: " + request.Type);
throw new TextureToolsException("ArrayTexLib can't handle this request: " + request.Type);
}
}
示例3: StartLibrary
public void StartLibrary(TexImage image)
{
if(image.Format.IsCompressed())
{
Log.Error("FreeImage can't process compressed texture.");
throw new TextureToolsException("FreeImage can't process compressed texture.");
}
var libraryData = new FreeImageTextureLibraryData();
image.LibraryData[this] = libraryData;
libraryData.Bitmaps = new FIBITMAP[image.SubImageArray.Length];
FREE_IMAGE_TYPE type;
uint bpp, redMask, greenMask, blueMask;
if (!FreeImage.GetFormatParameters(image.Format, out type, out bpp, out redMask, out greenMask, out blueMask))
{
throw new ArgumentException("The pixel format '{0}' is not supported by FreeImage".ToFormat(image.Format));
}
for (int i = 0; i < image.SubImageArray.Length; ++i)
{
var data = image.SubImageArray[i].Data;
var width = image.SubImageArray[i].Width;
var heigth = image.SubImageArray[i].Height;
var pitch = image.SubImageArray[i].RowPitch;
libraryData.Bitmaps[i] = FreeImage.ConvertFromRawBits(data, type, width, heigth, pitch, bpp, redMask, greenMask, blueMask, false);
}
if (image.DisposingLibrary != null) image.DisposingLibrary.Dispose(image);
image.DisposingLibrary = this;
libraryData.Data = IntPtr.Zero;
}
示例4: Execute
public void Execute(TexImage image, IRequest request)
{
if (image.GetType() != typeof(TexAtlas))
{
throw new TextureToolsException("The given texture must be an instance of TexAtlas.");
}
TexAtlas atlas = (TexAtlas)image;
switch (request.Type)
{
case RequestType.AtlasCreation:
Create(atlas, (AtlasCreationRequest)request, 0);
break;
case RequestType.AtlasExtraction:
Extract(atlas, (AtlasExtractionRequest)request);
break;
case RequestType.AtlasUpdate:
Update(atlas, (AtlasUpdateRequest)request);
break;
default:
Log.Error("AtlasTexLibrary can't handle this request: " + request.Type);
throw new TextureToolsException("AtlasTexLibrary can't handle this request: " + request.Type);
}
}
示例5: StartLibrary
public void StartLibrary(TexImage image)
{
if (image.LibraryData.ContainsKey(this) && ((DxtTextureLibraryData)image.LibraryData[this]).DxtImages[0].pixels.Equals(image.Data)) return;
DxtTextureLibraryData libraryData = new DxtTextureLibraryData();
image.LibraryData[this] = libraryData;
DXGI_FORMAT format = RetrieveNativeFormat(image.Format);
libraryData.DxtImages = new DxtImage[image.SubImageArray.Length];
for (int i = 0; i < image.SubImageArray.Length; ++i)
{
libraryData.DxtImages[i] = new DxtImage(image.SubImageArray[i].Width, image.SubImageArray[i].Height, format, image.SubImageArray[i].RowPitch, image.SubImageArray[i].SlicePitch, image.SubImageArray[i].Data);
}
switch (image.Dimension)
{
case TexImage.TextureDimension.Texture1D:
libraryData.Metadata = new TexMetadata(image.Width, image.Height, image.Depth, image.ArraySize, image.MipmapCount, 0, 0, format, TEX_DIMENSION.TEX_DIMENSION_TEXTURE1D); break;
case TexImage.TextureDimension.Texture2D:
libraryData.Metadata = new TexMetadata(image.Width, image.Height, image.Depth, image.ArraySize, image.MipmapCount, 0, 0, format, TEX_DIMENSION.TEX_DIMENSION_TEXTURE2D); break;
case TexImage.TextureDimension.Texture3D:
libraryData.Metadata = new TexMetadata(image.Width, image.Height, image.Depth, image.ArraySize, image.MipmapCount, 0, 0, format, TEX_DIMENSION.TEX_DIMENSION_TEXTURE3D); break;
case TexImage.TextureDimension.TextureCube:
libraryData.Metadata = new TexMetadata(image.Width, image.Height, image.Depth, image.ArraySize, image.MipmapCount, TEX_MISC_FLAG.TEX_MISC_TEXTURECUBE, 0, format, TEX_DIMENSION.TEX_DIMENSION_TEXTURE2D); break;
}
libraryData.Image = null;
}
示例6: FlipTest
public static void FlipTest(TexImage image, ITexLibrary library, Orientation orientation)
{
library.Execute(image, new FlippingRequest(orientation));
Assert.IsTrue(TestTools.ComputeSHA1(image.Data, image.DataSize).Equals(TestTools.GetInstance().Checksum["FlipTest_" + orientation + "_" + image.Name]));
//Console.WriteLine("FlipTest_" + orientation + "_" + image.Name + "." + TestTools.ComputeSHA1(image.Data, image.DataSize));
}
示例7: CanHandleRequest
public bool CanHandleRequest(TexImage image, IRequest request)
{
switch (request.Type)
{
case RequestType.Export:
{
string extension = Path.GetExtension(((ExportRequest)request).FilePath);
return extension.Equals(".dds") || extension.Equals(Extension);
}
case RequestType.ExportToXenko:
return true;
case RequestType.Loading: // Xenko can load dds file or his own format or a Xenko <see cref="Image"/> instance.
LoadingRequest load = (LoadingRequest)request;
if(load.Mode == LoadingRequest.LoadingMode.XkImage) return true;
else if(load.Mode == LoadingRequest.LoadingMode.FilePath)
{
string extension = Path.GetExtension(load.FilePath);
return extension.Equals(".dds") || extension.Equals(Extension);
} else return false;
}
return false;
}
示例8: DecompressTest
public static void DecompressTest(TexImage image, ITexLibrary library)
{
Assert.IsTrue(image.Format.IsCompressed());
library.Execute(image, new DecompressingRequest(false));
Assert.IsTrue(image.Format == PixelFormat.R8G8B8A8_UNorm);
Assert.IsTrue(TestTools.ComputeSHA1(image.Data, image.DataSize).Equals(TestTools.GetInstance().Checksum["DecompressTest_" + image.Name]));
//Console.WriteLine("DecompressTest_" + image.Name + "." + TestTools.ComputeSHA1(image.Data, image.DataSize));
}
示例9: Load
public static TexImage Load(ITexLibrary library, string file)
{
var image = new TexImage();
library.Execute(image, new LoadingRequest(InputTestFolder + file, false));
image.Name = file;
image.CurrentLibrary = library;
return image;
}
示例10: SwitchChannelsTest
public static void SwitchChannelsTest(TexImage image, ITexLibrary library)
{
var isInRgbaOrder = image.Format.IsRGBAOrder();
library.Execute(image, new SwitchingBRChannelsRequest());
Assert.IsTrue(image.Format.IsRGBAOrder() != isInRgbaOrder);
//Console.WriteLine("SwitchChannelsTest_" + image.Name + "." + TestTools.ComputeSHA1(image.Data, image.DataSize));
Assert.IsTrue(TestTools.ComputeSHA1(image.Data, image.DataSize).Equals(TestTools.GetInstance().Checksum["SwitchChannelsTest_" + image.Name]));
}
示例11: StartLibraryTest
/// <summary>
/// The purpose of this test is to show that after calling the StartLibrary method on a TexImage,
/// this image will contain in its LibraryData list the ITextureLibraryData instance corresponding
/// to the actual state of the TexImage.
/// An instance of ITextureLibraryData is creating at the load of the TexImage by the library so we
/// must delete it first for the sake of this test.
/// </summary>
public static void StartLibraryTest(TexImage image, ITexLibrary library)
{
image.LibraryData.Remove(library); // deleting the LibraryData instance
Assert.IsFalse(image.LibraryData.ContainsKey(library));
library.StartLibrary(image);
Assert.IsTrue(image.LibraryData.ContainsKey(library));
}
示例12: Dispose
public void Dispose(TexImage image)
{
if (!image.LibraryData.ContainsKey(this)) return;
PvrTextureLibraryData libraryData = (PvrTextureLibraryData)image.LibraryData[this];
if (libraryData.Texture != null)
{
libraryData.Header = null;
libraryData.Texture.Dispose();
}
}
示例13: Execute
public void Execute(TexImage image, IRequest request)
{
switch (request.Type)
{
case RequestType.ColorKey:
ApplyColorKey(image, (ColorKeyRequest)request);
break;
default:
Log.Error("ColorKeyTexLibrary can't handle this request: " + request.Type);
throw new TextureToolsException("ColorKeyTexLibrary can't handle this request: " + request.Type);
}
}
示例14: CanHandleRequest
public bool CanHandleRequest(TexImage image, IRequest request)
{
switch (request.Type)
{
case RequestType.Compressing:
return SupportFormat(((CompressingRequest)request).Format) && SupportFormat(image.Format);
case RequestType.Decompressing:
return SupportFormat(image.Format);
default:
return false;
}
}
示例15: StartLibraryTest
public void StartLibraryTest(string file)
{
TexImage image = new TexImage();
var dxtLib = new DxtTexLib();
dxtLib.Execute(image, new LoadingRequest(Module.PathToInputImages + file, false));
image.CurrentLibrary = dxtLib;
dxtLib.EndLibrary(image);
TexLibraryTest.StartLibraryTest(image, library);
image.Dispose();
}