mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Move IOStream to GpCommon
This commit is contained in:
@@ -1,77 +1,77 @@
|
||||
#include "QDPictHeader.h"
|
||||
#include "IOStream.h"
|
||||
#include "SharedTypes.h"
|
||||
#include "CoreDefs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
QDPictHeader::QDPictHeader()
|
||||
: m_pictVersion(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool QDPictHeader::Load(IOStream *stream)
|
||||
#include "QDPictHeader.h"
|
||||
#include "GpIOStream.h"
|
||||
#include "SharedTypes.h"
|
||||
#include "CoreDefs.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
namespace PortabilityLayer
|
||||
{
|
||||
QDPictHeader::QDPictHeader()
|
||||
: m_pictVersion(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool QDPictHeader::Load(GpIOStream *stream)
|
||||
{
|
||||
struct PictHeader
|
||||
{
|
||||
{
|
||||
uint8_t m_size[2];
|
||||
|
||||
BERect m_rect;
|
||||
BERect m_rect;
|
||||
};
|
||||
|
||||
GP_STATIC_ASSERT(sizeof(PictHeader) == 10);
|
||||
|
||||
PictHeader pictHeader;
|
||||
if (stream->Read(&pictHeader, sizeof(PictHeader)) != sizeof(PictHeader))
|
||||
return false;
|
||||
|
||||
m_frame = pictHeader.m_rect.ToRect();
|
||||
if (!m_frame.IsValid())
|
||||
return false;
|
||||
|
||||
uint8_t versionTag1[2];
|
||||
if (stream->Read(versionTag1, 2) != 2)
|
||||
return false;
|
||||
|
||||
if (versionTag1[0] == 0x11 && versionTag1[1] == 0x01)
|
||||
{
|
||||
m_pictVersion = 1;
|
||||
}
|
||||
else if (versionTag1[0] == 0x00 && versionTag1[1] == 0x11)
|
||||
{
|
||||
m_pictVersion = 2;
|
||||
|
||||
uint8_t v2Header[28];
|
||||
if (stream->Read(v2Header, 28) != 28)
|
||||
return false;
|
||||
|
||||
if (v2Header[0] != 0x02 || v2Header[1] != 0xff || v2Header[2] != 0x0c || v2Header[3] != 0x00)
|
||||
return false;
|
||||
|
||||
BEInt16_t v2Version;
|
||||
memcpy(&v2Version, v2Header + 4, 2);
|
||||
|
||||
// In version 2 header, v2Version == -1
|
||||
// Followed by fixed-point bounding rectangle (16 bytes) and 4 reserved
|
||||
// In ext. version 2 header, v2Version == -2
|
||||
// Followed by 2-byte reserved, horizontal DPI (fixed point, 4 bytes), vertical DPI (fixed point, 4 bytes) optimal source rect (8 bytes), and 2 reserved
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int QDPictHeader::GetVersion() const
|
||||
{
|
||||
return m_pictVersion;
|
||||
}
|
||||
|
||||
const Rect &QDPictHeader::GetFrame() const
|
||||
{
|
||||
return m_frame;
|
||||
}
|
||||
|
||||
GP_STATIC_ASSERT(sizeof(PictHeader) == 10);
|
||||
|
||||
PictHeader pictHeader;
|
||||
if (stream->Read(&pictHeader, sizeof(PictHeader)) != sizeof(PictHeader))
|
||||
return false;
|
||||
|
||||
m_frame = pictHeader.m_rect.ToRect();
|
||||
if (!m_frame.IsValid())
|
||||
return false;
|
||||
|
||||
uint8_t versionTag1[2];
|
||||
if (stream->Read(versionTag1, 2) != 2)
|
||||
return false;
|
||||
|
||||
if (versionTag1[0] == 0x11 && versionTag1[1] == 0x01)
|
||||
{
|
||||
m_pictVersion = 1;
|
||||
}
|
||||
else if (versionTag1[0] == 0x00 && versionTag1[1] == 0x11)
|
||||
{
|
||||
m_pictVersion = 2;
|
||||
|
||||
uint8_t v2Header[28];
|
||||
if (stream->Read(v2Header, 28) != 28)
|
||||
return false;
|
||||
|
||||
if (v2Header[0] != 0x02 || v2Header[1] != 0xff || v2Header[2] != 0x0c || v2Header[3] != 0x00)
|
||||
return false;
|
||||
|
||||
BEInt16_t v2Version;
|
||||
memcpy(&v2Version, v2Header + 4, 2);
|
||||
|
||||
// In version 2 header, v2Version == -1
|
||||
// Followed by fixed-point bounding rectangle (16 bytes) and 4 reserved
|
||||
// In ext. version 2 header, v2Version == -2
|
||||
// Followed by 2-byte reserved, horizontal DPI (fixed point, 4 bytes), vertical DPI (fixed point, 4 bytes) optimal source rect (8 bytes), and 2 reserved
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int QDPictHeader::GetVersion() const
|
||||
{
|
||||
return m_pictVersion;
|
||||
}
|
||||
|
||||
const Rect &QDPictHeader::GetFrame() const
|
||||
{
|
||||
return m_frame;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user