本文整理汇总了C#中System.Image.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Image.GetType方法的具体用法?C# Image.GetType怎么用?C# Image.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Image
的用法示例。
在下文中一共展示了Image.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: init
protected unsafe virtual bool init(IDisposableResource parent, Image image, int width, int height, bool generateMipmaps, MultiSampleTypes multiSampleType, SurfaceFormats surfaceFormat, RenderTargetUsage renderTargetUsage, BufferUsages usage, bool isRenderTarget, Loader.LoadedCallbackMethod loadedCallback)
{
try
{
if (usage == BufferUsages.Read && !isRenderTarget) Debug.ThrowError("Texture2D", "Only RenderTargets may be readable");
video = parent.FindParentOrSelfWithException<Video>();
if (isRenderTarget) generateMipmaps = false;
uint texturesTEMP = 0;
GL.GenTextures(1, &texturesTEMP);
Texture = texturesTEMP;
if (Texture == 0) Debug.ThrowError("Texture2D", "Failed to Generate Texture");
GL.BindTexture(GL.TEXTURE_2D, Texture);
if (!generateMipmaps) GL.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR);
else GL.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_LINEAR);
GL.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.LINEAR);
hasMipmaps = false;
if (image != null)
{
var imageType = image.GetType();
#if NaCl
if (imageType == typeof(ImageBMPC))
#else
if (imageType == typeof(ImagePNG) || imageType == typeof(ImageJPG) || imageType == typeof(ImageBMP) || imageType == typeof(ImageBMPC))
#endif
{
uint pixelOrder, byteSizes;
int format = Video.surfaceFormat(surfaceFormat, out pixelOrder, out byteSizes);
var mipmap = image.Mipmaps[0];
fixed (byte* data = mipmap.Data)
{
GL.TexImage2D(GL.TEXTURE_2D, 0, format, mipmap.Size.Width, mipmap.Size.Height, 0, pixelOrder, byteSizes, data);
if (generateMipmaps)
{
hasMipmaps = true;
GL.GenerateMipmap(GL.TEXTURE_2D);
}
}
}
else if (imageType == typeof(ImageDDS) || imageType == typeof(ImagePVR))
{
if (image.Mipmaps.Length != Image.Mipmap.CalculateMipmapLvls(image.Size.Width, image.Size.Height))
{
Debug.ThrowError("Texture2D", "Compressed Textures require full mipmap chain");
}
GL.TexParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_LINEAR);
hasMipmaps = true;
bool compressed = false;
uint format = 0;
string errorType = null;
if (imageType == typeof(ImageDDS))
{
var imageDDS = (ImageDDS)image;
compressed = imageDDS.Compressed;
format = imageDDS.FormatGL;
errorType = "DDS";
}
else if (imageType == typeof(ImagePVR))
{
var imagePVR = (ImagePVR)image;
compressed = imagePVR.Compressed;
format = imagePVR.FormatGL;
errorType = "PVR";
}
if (compressed)
{
for (int i = 0; i < image.Mipmaps.Length; ++i)
{
var mipmap = image.Mipmaps[i];
fixed (byte* data = mipmap.Data)
{
// look up:: libtxc_dxtn.so for linux with mesa
GL.CompressedTexImage2D(GL.TEXTURE_2D, i, format, mipmap.Size.Width, mipmap.Size.Height, 0, mipmap.Data.Length, data);
}
}
}
else
{
Debug.ThrowError("Texture2D", "Loading uncompresed " + errorType + " textures not supported");
}
}
Size = image.Size;
PixelByteSize = image.CalculatePixelByteSize();
}
else
{
//GL.TexImage2D(GL.TEXTURE_2D, 0, Video.surfaceFormat(surfaceFormat), width, height, 0, GL.RGBA, GL.UNSIGNED_BYTE, IntPtr.Zero.ToPointer());
uint pixelOrder, byteSizes;
int format = Video.surfaceFormat(surfaceFormat, out pixelOrder, out byteSizes);
GL.TexImage2D(GL.TEXTURE_2D, 0, format, width, height, 0, pixelOrder, byteSizes, IntPtr.Zero.ToPointer());
if (generateMipmaps)
{
hasMipmaps = true;
//.........这里部分代码省略.........
示例2: AddTemplateRelatedData
private void AddTemplateRelatedData(PageTemplate template, Image image, PageManager pageManager)
{
var changedRelations = new ContentLinkChange[]
{
new ContentLinkChange()
{
ChildItemId = image.Id,
ChildItemProviderName = image.GetProviderName(),
ChildItemType = image.GetType().FullName,
ComponentPropertyName = PageTemplate.ThumbnailFieldName,
Ordinal = -2,
State = Telerik.Sitefinity.Web.UI.Fields.Enums.ContentLinkChangeState.Added
}
};
var type = Type.GetType("Telerik.Sitefinity.RelatedData.RelatedDataHelper, Telerik.Sitefinity");
var method = type.GetMethod("SaveRelatedDataChanges", BindingFlags.NonPublic | BindingFlags.Static);
method.Invoke(null, new object[] { pageManager, template, changedRelations, false });
}