4 using System.Runtime.InteropServices;
6 using SiliconStudio.Core;
7 using SiliconStudio.Core.IO;
8 using SiliconStudio.Core.Serialization;
10 namespace SiliconStudio.
Paradox.Graphics
15 private const string MagicCodeString =
"TKTX";
16 private static readonly FourCC MagicCode =
"TKTX";
23 var magicCode = stream.ReadUInt32();
24 if (magicCode != MagicCode)
29 imageDescriptionSerializer.Serialize(ref imageDescription, ArchiveMode.Deserialize, stream);
33 var buffer = Utilities.AllocateMemory(
size);
34 Utilities.CopyMemory(buffer, pSource,
size);
39 var image =
new Image(imageDescription, pSource, 0, handle, !makeACopy);
41 var totalSizeInBytes = stream.ReadInt32();
42 if (totalSizeInBytes != image.TotalSizeInBytes)
43 throw new InvalidOperationException(
"Image size is different than expected.");
46 stream.Serialize(image.DataPointer, image.TotalSizeInBytes);
56 stream.Write(MagicCode);
59 imageDescriptionSerializer.Serialize(ref description, ArchiveMode.Serialize, stream);
63 foreach (var pixelBuffer
in pixelBuffers)
64 totalSize += pixelBuffer.BufferStride;
66 stream.Write(totalSize);
69 foreach (var pixelBuffer
in pixelBuffers)
71 stream.Serialize(pixelBuffer.DataPointer, pixelBuffer.BufferStride);
Provides method to instantiate an image 1D/2D/3D supporting TextureArray and mipmaps on the CPU or to...
Implements SerializationStream as a binary writer.
Implements SerializationStream as a binary reader.
A MemoryStream over a native memory region.
An unmanaged buffer of pixels.
static unsafe Image LoadFromMemory(IntPtr pSource, int size, bool makeACopy, GCHandle?handle)
Describes how to serialize and deserialize an object without knowing its type. Used as a common base ...
static void SaveFromMemory(PixelBuffer[] pixelBuffers, int count, ImageDescription description, System.IO.Stream imageStream)
_In_ size_t _In_ size_t size