mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
add image table reading
This commit is contained in:
@@ -14,9 +14,44 @@
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "../core/IStream.hpp"
|
||||
#include "../core/Memory.hpp"
|
||||
#include "ImageTable.h"
|
||||
|
||||
ImageTable::~ImageTable()
|
||||
{
|
||||
Memory::Free(_data);
|
||||
_data = nullptr;
|
||||
_dataSize = 0;
|
||||
}
|
||||
|
||||
void ImageTable::Read(IStream * stream)
|
||||
{
|
||||
// TODO
|
||||
uint32 numImages = stream->ReadValue<uint32>();
|
||||
uint32 imageDataSize = stream->ReadValue<uint32>();
|
||||
|
||||
_dataSize = imageDataSize;
|
||||
_data = Memory::Reallocate(_data, _dataSize);
|
||||
|
||||
// Read g1 element headers
|
||||
uintptr_t imageDataBase = (uintptr_t)_data;
|
||||
for (uint32 i = 0; i < numImages; i++)
|
||||
{
|
||||
rct_g1_element g1Element;
|
||||
|
||||
uintptr_t imageDataOffset = (uintptr_t)stream->ReadValue<uint32>();
|
||||
g1Element.offset = (uint8*)(imageDataBase + imageDataOffset);
|
||||
|
||||
g1Element.width = stream->ReadValue<sint16>();
|
||||
g1Element.height = stream->ReadValue<sint16>();
|
||||
g1Element.x_offset = stream->ReadValue<sint16>();
|
||||
g1Element.y_offset = stream->ReadValue<sint16>();
|
||||
g1Element.flags = stream->ReadValue<uint16>();
|
||||
g1Element.zoomed_offset = stream->ReadValue<uint16>();
|
||||
|
||||
_entries.push_back(g1Element);
|
||||
}
|
||||
|
||||
// Read g1 element data
|
||||
stream->Read(_data, _dataSize);
|
||||
}
|
||||
|
||||
@@ -16,12 +16,25 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "../common.h"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
#include "../drawing/drawing.h"
|
||||
}
|
||||
|
||||
interface IStream;
|
||||
|
||||
class ImageTable
|
||||
{
|
||||
private:
|
||||
std::vector<rct_g1_element> _entries;
|
||||
void * _data = nullptr;
|
||||
size_t _dataSize = 0;
|
||||
|
||||
public:
|
||||
~ImageTable();
|
||||
|
||||
void Read(IStream * stream);
|
||||
};
|
||||
Reference in New Issue
Block a user