1
0
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:
Ted John
2016-06-25 10:48:54 +01:00
parent 463e88583d
commit 28ae0cbee6
2 changed files with 49 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -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);
};