本文整理汇总了C#中Texture.CreateFromBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.CreateFromBitmap方法的具体用法?C# Texture.CreateFromBitmap怎么用?C# Texture.CreateFromBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Texture
的用法示例。
在下文中一共展示了Texture.CreateFromBitmap方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Import
public override Asset Import(string path)
{
Texture texture = new Texture();
texture.FileName = path;
PIX pix = PIX.Load(path);
texture.CreateFromBitmap(pix.Pixies[0].GetBitmap(), pix.Pixies[0].Name);
return texture;
}
示例2: Import
public override Asset Import(string path)
{
var img = IMG.Load(path);
Texture texture = new Texture();
texture.CreateFromBitmap(img.ExportToBitmap(), Path.GetFileNameWithoutExtension(path));
texture.FileName = path;
return texture;
}
示例3: Import
public override Asset Import(string path)
{
Texture texture = new Texture();
texture.FileName = path;
using (var bitmap = new Bitmap(path)) { texture.CreateFromBitmap(bitmap, Path.GetFileNameWithoutExtension(path)); }
return texture;
}
示例4: Import
public override Asset Import(string path)
{
Texture texture = new Texture();
texture.FileName = path;
var fi = new FileInfo(path);
using (var bitmap = new Bitmap(path)) { texture.CreateFromBitmap(bitmap, fi.Name.Replace(fi.Extension, "")); }
return texture;
}
示例5: Import
public override Asset Import(string path)
{
Texture texture = new Texture();
texture.FileName = path;
if (string.Compare(Path.GetExtension(path), ".tif", true) == 0)
{
using (var bitmap = new Bitmap(path)) { texture.CreateFromBitmap(bitmap, Path.GetFileNameWithoutExtension(path)); }
}
else
{
texture = (Texture)(new PIXImporter()).Import(path);
}
return texture;
}
示例6: ImportMany
public override AssetList ImportMany(string path)
{
TextureList textures = new TextureList();
var pix = PIX.Load(path);
foreach (var pixelmap in pix.Pixies)
{
Texture texture = new Texture();
texture.CreateFromBitmap(pixelmap.GetBitmap(), pixelmap.Name);
textures.Entries.Add(texture);
}
//texture.SetData(tdx.Name, tdx.Format.ToString(), tdx.MipMaps[0].Width, tdx.MipMaps[0].Height, tdx.MipMaps[0].Data);
//texture.SupportingDocuments["Source"] = tdx;
//texture.FileName = path;
return textures;
}
示例7: Import
public override Asset Import(string path)
{
Texture texture = new Texture();
texture.FileName = path;
var fi = new FileInfo(path);
using (var br = new BinaryReader(fi.OpenRead()))
{
byte idLength = br.ReadByte();
byte colourMapType = br.ReadByte();
byte imageType = br.ReadByte();
if (idLength > 0) { throw new NotImplementedException("No support for TGA files with ID sections!"); }
if (colourMapType == 0) { br.ReadBytes(5); } else { throw new NotImplementedException("No support for TGA files with ColourMaps!"); }
int xOrigin = br.ReadInt16();
int yOrigin = br.ReadInt16();
int width = br.ReadInt16();
int height = br.ReadInt16();
byte pixelDepth = br.ReadByte();
byte imageDescriptor = br.ReadByte();
using (var bmp = new Bitmap(width, height, PixelFormat.Format32bppArgb))
{
BitmapData bmpdata;
PixelFormat format = PixelFormat.Format32bppArgb;
byte size = (byte)(pixelDepth / 8);
if (size == 3) { format = PixelFormat.Format24bppRgb; }
bmpdata = bmp.LockBits(new Rectangle(0, 0, width, height), ImageLockMode.ReadWrite, format);
if (imageType == 10)
{
const int iRAWSection = 127;
uint j = 0;
int iStep = 0;
int bpCount = 0;
int currentPixel = 0;
int pixelCount = width * height;
var colorBuffer = new byte[size];
byte chunkHeader = 0;
byte[] buffer = br.ReadBytes((int)br.BaseStream.Length - 13);
using (var nms = new MemoryStream())
{
while (currentPixel < pixelCount)
{
chunkHeader = buffer[iStep];
iStep++;
if (chunkHeader <= iRAWSection)
{
chunkHeader++;
bpCount = size * chunkHeader;
nms.Write(buffer, iStep, bpCount);
iStep += bpCount;
currentPixel += chunkHeader;
}
else
{
chunkHeader -= iRAWSection;
Array.Copy(buffer, iStep, colorBuffer, 0, size);
iStep += size;
for (j = 0; j < chunkHeader; j++) { nms.Write(colorBuffer, 0, size); }
currentPixel += chunkHeader;
}
}
var contentBuffer = new byte[nms.Length];
nms.Position = 0;
nms.Read(contentBuffer, 0, contentBuffer.Length);
Marshal.Copy(contentBuffer, 0, bmpdata.Scan0, contentBuffer.Length);
}
}
else
{
Marshal.Copy(br.ReadBytes(width * height * size), 0, bmpdata.Scan0, width * height * size);
}
bmp.UnlockBits(bmpdata);
texture.CreateFromBitmap(bmp, Path.GetFileNameWithoutExtension(path));
}
}
return texture;
}