mirror of
https://github.com/crskycode/GARbro.git
synced 2024-11-23 21:55:34 +08:00
(TgaStream): new static class.
create TGA image stream from the given image meta-data and pixels array.
This commit is contained in:
parent
ca919c1ee9
commit
abe08cd457
@ -23,12 +23,11 @@
|
||||
// IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using GameRes.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace GameRes.Formats
|
||||
{
|
||||
@ -409,6 +408,26 @@ namespace GameRes.Formats
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create stream in TGA format from the given image pixels.
|
||||
/// </summary>
|
||||
public static class TgaStream
|
||||
{
|
||||
public static Stream Create (ImageMetaData info, byte[] pixels, bool flipped = false)
|
||||
{
|
||||
var header = new byte[0x12];
|
||||
header[2] = 2;
|
||||
LittleEndian.Pack ((short)info.OffsetX, header, 8);
|
||||
LittleEndian.Pack ((short)info.OffsetY, header, 0xa);
|
||||
LittleEndian.Pack ((ushort)info.Width, header, 0xc);
|
||||
LittleEndian.Pack ((ushort)info.Height, header, 0xe);
|
||||
header[0x10] = (byte)info.BPP;
|
||||
if (!flipped)
|
||||
header[0x11] = 0x20;
|
||||
return new PrefixStream (header, new MemoryStream (pixels));
|
||||
}
|
||||
}
|
||||
|
||||
public static class MMX
|
||||
{
|
||||
public static ulong PAddB (ulong x, ulong y)
|
||||
|
Loading…
Reference in New Issue
Block a user