本文整理匯總了C#中SharpDX.Direct3D9.Texture.UnlockRectangle方法的典型用法代碼示例。如果您正苦於以下問題:C# Texture.UnlockRectangle方法的具體用法?C# Texture.UnlockRectangle怎麽用?C# Texture.UnlockRectangle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SharpDX.Direct3D9.Texture
的用法示例。
在下文中一共展示了Texture.UnlockRectangle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateTexture
public unsafe Texture CreateTexture(int index)
{
if (!_fileIndex.FilesExist)
return null;
int length, extra;
bool patched;
Stream stream = _fileIndex.Seek(index, out length, out extra, out patched);
if (stream == null)
return null;
int size = extra == 0 ? 64 : 128;
Texture texture = new Texture(_device, size, size, 0, Usage.None, Format.A1R5G5B5, Pool.Managed);
DataRectangle rect = texture.LockRectangle(0, LockFlags.None);
BinaryReader bin = new BinaryReader(stream);
ushort* line = (ushort*)rect.DataPointer;
int delta = rect.Pitch >> 1;
for (int y = 0; y < size; ++y, line += delta)
{
ushort* cur = line;
ushort* end = cur + size;
while (cur < end)
*cur++ = (ushort)(bin.ReadUInt16() ^ 0x8000);
}
texture.UnlockRectangle(0);
return texture;
}
示例2: Hues
public Hues(Engine engine)
{
IConfigurationService configurationService = engine.Kernel.Get<IConfigurationService>();
string ultimaOnlineDirectory = configurationService.GetValue<string>(ConfigSections.UltimaOnline, ConfigKeys.UltimaOnlineDirectory);
if (!Directory.Exists(ultimaOnlineDirectory))
{
_filesExist = false;
return;
}
string path = Path.Combine(ultimaOnlineDirectory, "hues.mul");
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
{
BinaryReader bin = new BinaryReader(fs);
int blockCount = (int)fs.Length / 708;
if (blockCount > 375)
blockCount = 375;
_hues = new Texture[blockCount];
for (int i = 0; i < blockCount; ++i)
{
bin.ReadInt32();
Texture texture = new Texture(engine.Device, 34, 1, 0, Usage.None, Format.A1R5G5B5, Pool.Managed); ;
IntPtr dataPtr = texture.LockRectangle(0, LockFlags.None).DataPointer;
unsafe
{
ushort* line = (ushort*)dataPtr;
for (int j = 0; j < 34; j++)
(*line++) = (ushort)(bin.ReadUInt16() | 0x8000);
texture.UnlockRectangle(0);
bin.ReadBytes(20); //Don't need to know the names
_hues[i] = texture;
}
}
}
}
示例3: InternalDDSFromStream
//loads the data from a stream in to a texture object.
private static void InternalDDSFromStream(Stream stream, Device device, int streamOffset, bool loadMipMap, int offsetMipMaps, out SharpDX.Direct3D9.Texture texture)
{
stream.Position = 0;
if (offsetMipMaps == 0)
{
texture = SharpDX.Direct3D9.Texture.FromStream(device, stream, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
}
else
{
texture = SharpDX.Direct3D9.Texture.FromStream(device, stream, 0, 0, 0, Usage.Dynamic, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
int width = MipMapSize(offsetMipMaps, texture.GetLevelDescription(0).Width);
int height = MipMapSize(offsetMipMaps, texture.GetLevelDescription(0).Height);
int maxLevels = Math.Min(MaxMipMapLevels(width), MaxMipMapLevels(height));
int actualLevels = Math.Min(maxLevels, texture.LevelCount - offsetMipMaps);
Format format = texture.GetLevelDescription(0).Format;
Texture offsetedTexture = new Texture(device, width, height, actualLevels, Usage.Dynamic, format, Pool.Default);
for (int i = offsetMipMaps, j = 0; j < actualLevels; i++, j++)
{
int levelWidth = MipMapSize(j, width);
int levelHeight = MipMapSize(j, height);
SharpDX.DataStream ds;
texture.LockRectangle(i, LockFlags.ReadOnly, out ds);
texture.UnlockRectangle(i);
SharpDX.DataStream ds2;
offsetedTexture.LockRectangle(j, LockFlags.None, out ds2);
ds2.Position = 0;
ds2.Write(ds.DataPointer, 0, (int)MipMapSizeInBytes(levelWidth, levelHeight, format));
offsetedTexture.UnlockRectangle(j);
}
texture.Dispose();
texture = offsetedTexture;
}
}
示例4: Allocate
public override void Allocate()
{
lock (_syncObj)
{
if (!IsAllocated)
{
byte[] buffer = new byte[TEXTURE_SIZE * TEXTURE_SIZE * 4];
int offset = 0;
while (offset < TEXTURE_SIZE * TEXTURE_SIZE * 4)
{
buffer[offset++] = _color.R;
buffer[offset++] = _color.G;
buffer[offset++] = _color.B;
buffer[offset++] = _color.A;
}
_texture = new Texture(GraphicsDevice.Device, TEXTURE_SIZE, TEXTURE_SIZE, 1, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);
DataStream dataStream;
_texture.LockRectangle(0, LockFlags.None, out dataStream);
using (dataStream)
{
dataStream.Write(buffer, 0, buffer.Length);
_texture.UnlockRectangle(0);
}
_width = TEXTURE_SIZE;
_height = TEXTURE_SIZE;
_allocationSize = TEXTURE_SIZE * TEXTURE_SIZE * 4;
}
}
// Don't hold a lock while calling external code
FireAllocationChanged(_allocationSize);
}
示例5: CreateTexture
public unsafe Texture CreateTexture(int index)
{
if (!_fileIndex.FilesExist)
return null;
int length, extra;
bool patched;
Stream stream = _fileIndex.Seek(index, out length, out extra, out patched);
if (stream == null)
return null;
int width = (extra >> 16) & 0xFFFF;
int height = extra & 0xFFFF;
if (width == 0 || height == 0)
return null;
Texture texture = new Texture(_device, width, height, 0, Usage.None, Format.A1R5G5B5, Pool.Managed);
DataRectangle rect = texture.LockRectangle(0, LockFlags.None);
BinaryReader bin = new BinaryReader(stream);
int[] lookups = new int[height];
int start = (int)bin.BaseStream.Position;
for (int i = 0; i < height; ++i)
lookups[i] = start + (bin.ReadInt32() * 4);
ushort* line = (ushort*)rect.DataPointer;
int delta = rect.Pitch >> 1;
for (int y = 0; y < height; ++y, line += delta)
{
bin.BaseStream.Seek(lookups[y], SeekOrigin.Begin);
ushort* cur = line;
ushort* end = line + width;
while (cur < end)
{
ushort color = bin.ReadUInt16();
ushort* next = cur + bin.ReadUInt16();
if (color == 0)
{
cur = next;
}
else
{
color ^= 0x8000;
while (cur < next)
*cur++ = color;
}
}
}
texture.UnlockRectangle(0);
return texture;
}
示例6: InternalDDSFromStream
private static void InternalDDSFromStream(Stream stream, Device device, int streamOffset, bool loadMipMap, int offsetMipMaps, out SharpDX.Direct3D9.Texture texture)
{
var fileStream = stream as FileStream;
byte[] data = fileStream != null ? null : SharpDX.Utilities.ReadStream(stream);
int maxTextureDimension = MyRender.GraphicsDevice.Capabilities.MaxTextureWidth;
if (IntPtr.Size == 4 || MyRender.GraphicsDevice.AvailableTextureMemory < 1024 * 1024 * 600)
{
maxTextureDimension = 2048;
}
ImageInformation imageInfo;
if (fileStream != null)
{
//imageInfo = GetImageInfoFromFileW(fileStream.Name);
imageInfo = (ImageInformation)GetImageInfoFromFileWMethodInfo.Invoke(null, new object[] { fileStream.Name });
}
else
{
imageInfo = ImageInformation.FromMemory(data);
}
var textureWidth = imageInfo.Width;
var textureHeight = imageInfo.Height;
textureWidth = Math.Max(1, textureWidth >> offsetMipMaps);
textureHeight = Math.Max(1, textureHeight >> offsetMipMaps);
int loadMipmapOffset = offsetMipMaps;
while (textureWidth > maxTextureDimension || textureHeight > maxTextureDimension)
{
loadMipmapOffset++;
textureWidth = Math.Max(1, textureWidth >> 1);
textureHeight = Math.Max(1, textureHeight >> 1);
}
if (offsetMipMaps == 0 && loadMipmapOffset == 0)
{
if (fileStream != null)
{
texture = SharpDX.Direct3D9.Texture.FromFile(device, fileStream.Name, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, Filter.Linear, 0);
}
else
{
texture = SharpDX.Direct3D9.Texture.FromMemory(device, data, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, Filter.Linear, 0);
}
}
else if (loadMipmapOffset > 0)
{
var skipFilter = (Filter)D3DXSkipDDSMipLevels((uint)loadMipmapOffset);
if (fileStream != null)
{
texture = SharpDX.Direct3D9.Texture.FromFile(device, fileStream.Name, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, skipFilter, 0);
}
else
{
texture = SharpDX.Direct3D9.Texture.FromMemory(device, data, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, skipFilter, 0);
}
}
else
{
if (fileStream != null)
{
texture = SharpDX.Direct3D9.Texture.FromFile(device, fileStream.Name, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
}
else
{
texture = SharpDX.Direct3D9.Texture.FromMemory(device, data, 0, 0, 0, Usage.None, Format.Unknown, Pool.Default, Filter.None, Filter.None, 0);
}
int width = MipMapSize(offsetMipMaps, texture.GetLevelDescription(0).Width);
int height = MipMapSize(offsetMipMaps, texture.GetLevelDescription(0).Height);
int maxLevels = Math.Min(MaxMipMapLevels(width), MaxMipMapLevels(height));
int actualLevels = Math.Min(maxLevels, texture.LevelCount - offsetMipMaps);
Format format = texture.GetLevelDescription(0).Format;
Texture offsetedTexture = new Texture(device, width, height, actualLevels, Usage.Dynamic, format, Pool.Default);
for (int i = offsetMipMaps, j = 0; j < actualLevels; i++, j++)
{
int levelWidth = MipMapSize(j, width);
int levelHeight = MipMapSize(j, height);
SharpDX.DataStream ds;
texture.LockRectangle(i, LockFlags.ReadOnly, out ds);
texture.UnlockRectangle(i);
SharpDX.DataStream ds2;
offsetedTexture.LockRectangle(j, LockFlags.None, out ds2);
ds2.Position = 0;
ds2.Write(ds.DataPointer, 0, (int)MipMapSizeInBytes(levelWidth, levelHeight, format));
offsetedTexture.UnlockRectangle(j);
}
texture.Dispose();
texture = offsetedTexture;
}
}
示例7: CreateRandomTexture
static Texture CreateRandomTexture()
{
Random r = new Random();
int size = 256;
float[] rnd = new float[size];
for (int i = 0; i < size; i++)
{
rnd[i] = MyUtils.GetRandomFloat(-1, 1);
}
var result = new Texture(GraphicsDevice, size, 1, 0, Usage.None, Format.R32F, Pool.Managed);
DataStream ds;
result.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(rnd);
result.UnlockRectangle(0);
return result;
}
示例8: GenerateGradTexture4d
private void GenerateGradTexture4d()
{
if (gradTexture4d != null)
gradTexture4d.Dispose();
//NormalizedByte4
gradTexture4d = new Texture(MyRender.GraphicsDevice, 32, 1, 0, Usage.Dynamic, Format.Q8W8V8U8, Pool.Default);
NormalizedByte4[] data = new NormalizedByte4[32 * 1];
for (int x = 0; x < 32; x++)
{
for (int y = 0; y < 1; y++)
{
data[x + (y * 32)] = new NormalizedByte4(g4[x, 0], g4[x, 1], g4[x, 2], g4[x, 3]);
//data[31 - x + (y * 32)] = new NormalizedByte4(0, 0, 0, 0);
}
}
SharpDX.DataStream ds;
DataRectangle dr = gradTexture4d.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
gradTexture4d.UnlockRectangle(0);
}
示例9: GeneratePermGrad4dTexture
private void GeneratePermGrad4dTexture()
{ //NormalizedByte4
permGrad4dTexture = new Texture(MyRender.GraphicsDevice, 256, 1, 0, Usage.Dynamic, Format.Q8W8V8U8, Pool.Default);
NormalizedByte4[] data = new NormalizedByte4[256 * 1];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 1; y++)
{
data[x + (y * 256)] = new NormalizedByte4(g4[perm[x] % 32, 0], g4[perm[x] % 32, 1], g4[perm[x] % 32, 2], g4[perm[x] % 32, 3]);
}
}
SharpDX.DataStream ds;
DataRectangle dr = permGrad4dTexture.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
permGrad4dTexture.UnlockRectangle(0);
}
示例10: GeneratePermGradTexture
// permuted gradient texture for optimized version
private void GeneratePermGradTexture()
{
if (permGradTexture != null)
permGradTexture.Dispose();
//NormalizedByte4
permGradTexture = new Texture(MyRender.GraphicsDevice, 256, 1, 0, Usage.Dynamic, Format.Q8W8V8U8, Pool.Default);
NormalizedByte4[] data = new NormalizedByte4[256 * 1];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 1; y++)
{
//data[x + (y * 256)] = new NormalizedByte4(g3[perm[x] % 16, 0], g3[perm[x] % 16, 1], g3[perm[x] % 16, 2], 1);
data[x + (y * 256)] = new NormalizedByte4(g3[perm[x] % 16, 0], g3[perm[x] % 16, 1], g3[perm[x] % 16, 2], 1);
}
}
/*
byte[] data = new byte[256 * 1 * 4];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 1; y++)
{
data[(x + (y * 256)) * 4 + 0] = (byte)(255.0f * ((g3[perm[x] % 16, 0] + 1) / 2.0f));
data[(x + (y * 256)) * 4 + 1] = (byte)(255.0f * ((g3[perm[x] % 16, 1] + 1) / 2.0f));
data[(x + (y * 256)) * 4 + 2] = (byte)(255.0f * ((g3[perm[x] % 16, 2] + 1) / 2.0f));
data[(x + (y * 256)) * 4 + 3] = 1;
}
} */
SharpDX.DataStream ds;
DataRectangle dr = permGradTexture.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
permGradTexture.UnlockRectangle(0);
}
示例11: GenerateGradTexture
private void GenerateGradTexture()
{ //NormalizedByte4
gradTexture = new Texture(MyRender.GraphicsDevice, 16, 1, 0, Usage.Dynamic, Format.Q8W8V8U8, Pool.Default);
NormalizedByte4[] data = new NormalizedByte4[16 * 1];
for (int x = 0; x < 16; x++)
{
for (int y = 0; y < 1; y++)
{
data[x + (y * 16)] = new NormalizedByte4(g3[x, 0], g3[x, 1], g3[x, 2], 1);
}
}
SharpDX.DataStream ds;
DataRectangle dr = gradTexture.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
gradTexture.UnlockRectangle(0);
}
示例12: GeneratePermTexture2d
private void GeneratePermTexture2d()
{
if (permTexture2d != null)
permTexture2d.Dispose();
permTexture2d = new Texture(MyRender.GraphicsDevice, 256, 256, 0, Usage.Dynamic, Format.A8R8G8B8, Pool.Default);
Color[] data = new Color[256 * 256];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 256; y++)
{
int A = perm2d(x) + y;
int AA = perm2d(A);
int AB = perm2d(A + 1);
int B = perm2d(x + 1) + y;
int BA = perm2d(B);
int BB = perm2d(B + 1);
//data[x + (y * 256)] = new Color((byte)(AA / 255.0), (byte)(AB / 255.0),
// (byte)(BA / 255.0), (byte)(BB / 255.0));
//XNA Color = r g b a
//need a r g b
data[x + (y * 256)] = new Color((byte)(BA), (byte)(AB), (byte)(AA), (byte)(BB));
}
}
SharpDX.DataStream ds;
DataRectangle dr = permTexture2d.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
permTexture2d.UnlockRectangle(0);
}
示例13: GeneratePermTexture
private void GeneratePermTexture()
{
if (permTexture != null)
permTexture.Dispose();
permTexture = new Texture(MyRender.GraphicsDevice, 256, 1, 0, Usage.Dynamic, Format.L8, Pool.Default);
byte[] data = new byte[256 * 1];
for (int x = 0; x < 256; x++)
{
for (int y = 0; y < 1; y++)
{
data[x + (y * 256)] = (byte)(perm[x]);// / 255.0);
}
}
SharpDX.DataStream ds;
DataRectangle dr = permTexture.LockRectangle(0, LockFlags.None, out ds);
ds.WriteRange(data);
permTexture.UnlockRectangle(0);
}
示例14: SaveScreenshot
public static void SaveScreenshot(Texture texture2D, string file)
{
MyMwcLog.WriteLine("MyScreenshot.SaveTexture2D() - START");
MyMwcLog.IncreaseIndent();
Texture systemTex = new Texture(MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice, texture2D.GetLevelDescription(0).Width, texture2D.GetLevelDescription(0).Height, 0, Usage.None, Format.A8R8G8B8, Pool.SystemMemory);
Surface sourceSurface = texture2D.GetSurfaceLevel(0);
Surface destSurface = systemTex.GetSurfaceLevel(0);
MinerWars.AppCode.App.MyMinerGame.Static.GraphicsDevice.GetRenderTargetData(sourceSurface, destSurface);
sourceSurface.Dispose();
destSurface.Dispose();
texture2D = systemTex;
try
{
MyMwcLog.WriteLine("File: " + file);
MyFileSystemUtils.CreateFolderForFile(file);
Stack<SharpDX.Rectangle> tiles = new Stack<SharpDX.Rectangle>();
int tileWidth = texture2D.GetLevelDescription(0).Width;
int tileHeight = texture2D.GetLevelDescription(0).Height;
while (tileWidth > 3200)
{
tileWidth /= 2;
tileHeight /= 2;
}
int widthOffset = 0;
int heightOffset = 0;
while (widthOffset < texture2D.GetLevelDescription(0).Width)
{
while (heightOffset < texture2D.GetLevelDescription(0).Height)
{
tiles.Push(new SharpDX.Rectangle(widthOffset, heightOffset, tileWidth, tileHeight));
heightOffset += tileHeight;
}
heightOffset = 0;
widthOffset += tileWidth;
}
int sc = 0;
while (tiles.Count > 0)
{
SharpDX.Rectangle rect = tiles.Pop();
byte[] data = new byte[rect.Width * rect.Height * 4];
SharpDX.Rectangle rect2 = new SharpDX.Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
//texture2D.GetData<byte>(0, rect2, data, 0, data.Length);
DataStream ds;
texture2D.LockRectangle(0, rect2, LockFlags.None, out ds);
ds.Read(data, 0, data.Length);
/*
for (int i = 0; i < data.Length; i += 4)
{
//Swap ARGB <-> RGBA
byte b = data[i + 0];
byte g = data[i + 1];
byte r = data[i + 2];
byte a = data[i + 3];
data[i + 0] = r; //Blue
data[i + 1] = g; //Green
data[i + 2] = b; //Red
data[i + 3] = a; //Alpha
} */
ds.Seek(0, SeekOrigin.Begin);
ds.WriteRange(data);
texture2D.UnlockRectangle(0);
string filename = file.Replace(".png", "_" + sc.ToString("##00") + ".png");
using (Stream stream = File.Create(filename))
{
System.Drawing.Bitmap image = new System.Drawing.Bitmap(rect.Width, rect.Height);
System.Drawing.Imaging.BitmapData imageData = image.LockBits(new System.Drawing.Rectangle(0,0,rect.Width, rect.Height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Runtime.InteropServices.Marshal.Copy(data, 0, imageData.Scan0, data.Length);
image.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
image.UnlockBits(imageData);
image.Dispose();
//texture2D.SaveAsPng(stream, texture2D.Width, texture2D.Height);
//BaseTexture.ToStream(texture2D, ImageFileFormat.Png);
}
sc++;
GC.Collect();
}
}
//.........這裏部分代碼省略.........
示例15: SaveScreenshot
public static string SaveScreenshot(Texture tex, string file)
{
MyRender.Log.WriteLine("MyScreenshot.SaveTexture2D() - START");
MyRender.Log.IncreaseIndent();
string filename = null;
using (Texture systemTex = new Texture(MyRender.GraphicsDevice, tex.GetLevelDescription(0).Width, tex.GetLevelDescription(0).Height, 1, Usage.None, Format.A8R8G8B8, Pool.SystemMemory))
{
string extension = Path.GetExtension(file);
using (Surface sourceSurface = tex.GetSurfaceLevel(0))
using (Surface destSurface = systemTex.GetSurfaceLevel(0))
{
MyRender.GraphicsDevice.GetRenderTargetData(sourceSurface, destSurface);
}
try
{
MyRender.Log.WriteLine("File: " + file);
Stack<SharpDX.Rectangle> tiles = new Stack<SharpDX.Rectangle>();
int tileWidth = systemTex.GetLevelDescription(0).Width;
int tileHeight = systemTex.GetLevelDescription(0).Height;
while (tileWidth > 3200)
{
tileWidth /= 2;
tileHeight /= 2;
}
int widthOffset = 0;
int heightOffset = 0;
while (widthOffset < systemTex.GetLevelDescription(0).Width)
{
while (heightOffset < systemTex.GetLevelDescription(0).Height)
{
tiles.Push(new SharpDX.Rectangle(widthOffset, heightOffset, widthOffset + tileWidth, heightOffset + tileHeight));
heightOffset += tileHeight;
}
heightOffset = 0;
widthOffset += tileWidth;
}
bool multipleTiles = tiles.Count > 1;
int sc = 0;
byte[] data = new byte[tileWidth * tileHeight * 4];
int sysTexWidth = systemTex.GetLevelDescription(0).Width;
int sysTexHeight = systemTex.GetLevelDescription(0).Height;
while (tiles.Count > 0)
{
SharpDX.Rectangle rect = tiles.Pop();
//texture2D.GetData<byte>(0, rect2, data, 0, data.Length);
DataStream ds;
//DataRectangle dr = texture2D.LockRectangle(0, rect2, LockFlags.ReadOnly, out ds);
DataRectangle dr = systemTex.LockRectangle(0, LockFlags.ReadOnly, out ds);
//we have to go line by line..
ds.Seek(rect.Y * sysTexWidth * 4, SeekOrigin.Begin);
int targetOffset = 0;
int linesCount = tileHeight;
int pixelsBefore = rect.X;
int pixelsAfter = sysTexWidth - tileWidth - rect.X;
while (linesCount-- > 0)
{
if (pixelsBefore > 0)
ds.Seek(pixelsBefore * 4, SeekOrigin.Current);
ds.Read(data, targetOffset, tileWidth * 4);
targetOffset += tileWidth * 4;
if (pixelsAfter > 0 && linesCount > 0)
ds.Seek(pixelsAfter * 4, SeekOrigin.Current);
}
systemTex.UnlockRectangle(0);
filename = file;
if (multipleTiles)
{
filename = file.Replace(extension, "_" + sc.ToString("##00") + extension);
}
using (var stream = MyFileSystem.OpenWrite(MyFileSystem.UserDataPath, filename))
{
using (System.Drawing.Bitmap image = new System.Drawing.Bitmap(tileWidth, tileHeight))
{
System.Drawing.Imaging.BitmapData imageData = image.LockBits(new System.Drawing.Rectangle(0, 0, tileWidth, tileHeight), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
System.Runtime.InteropServices.Marshal.Copy(data, 0, imageData.Scan0, data.Length);
if (extension == ".png")
//.........這裏部分代碼省略.........