leonardovsilva
New Member
- Joined
- Apr 21, 2022
- Messages
- 6
- Reaction score
- 2
Can someone help me? I’d like to export that RME view into a high-scale PNG. Does anyone know how to do this?
I was looking at the RME code and got stuck.
When it retrieves the Tile, how could I write this into the image buffer?
I was thinking of an 8x image, meaning 32/4.
bool IOMinimap::exportMinimap(const std::string& directory)
{
auto& map = m_editor->getMap();
if(map.size() == 0) {
return true;
}
wxRect bounds[rme::MapLayers];
int min_z = m_floor == -1 ? 0 : m_floor;
int max_z = m_floor == -1 ? rme::MapMaxLayer : m_floor;
for (size_t z = min_z; z <= max_z; z++) {
auto& rect = bounds[z];
rect.x = rme::MapMaxWidth + 1;
rect.y = rme::MapMaxHeight + 1;
rect.width = 0;
rect.height = 0;
}
for(auto it = map.begin(); it != map.end(); ++it) {
auto tile = (*it)->get();
if(!tile || (!tile->ground && tile->items.empty())) {
continue;
}
const auto& position = tile->getPosition();
auto& rect = bounds[position.z];
if(position.x < rect.x) {
rect.x = position.x;
}
if(position.y < rect.y) {
rect.y = position.y;
}
if (position.x > rect.width) {
rect.width = position.x;
}
if (position.y > rect.height) {
rect.height = position.y;
}
}
constexpr int image_size = 1024;
constexpr int pixels_size = image_size * image_size * rme:
ixelFormatRGB;
uint8_t* pixels = new uint8_t[pixels_size];
auto image = new wxImage(image_size, image_size, pixels, true);
for(size_t z = min_z; z <= max_z; z++) {
auto& rect = bounds[z];
if(rect.IsEmpty()) {
continue;
}
for (int h = 0; h < rme::MapMaxHeight; h += image_size) {
for (int w = 0; w < rme::MapMaxWidth; w += image_size) {
if (w < rect.x || w > rect.width || h < rect.y || h > rect.height) {
continue;
}
bool empty = true;
memset(pixels, 0, pixels_size);
int index = 0;
for (int y = 0; y < image_size; y++) {
for (int x = 0; x < image_size; x++) {
auto tile = map.getTile(w + x, h + y, z);
if(!tile || (!tile->ground && tile->items.empty())) {
index += rme:
ixelFormatRGB;
continue;
}
uint8_t color = tile->getMiniMapColor();
pixels[index ] = (uint8_t)(static_cast<int>(color / 36) % 6 * 51); // red
pixels[index+1] = (uint8_t)(static_cast<int>(color / 6) % 6 * 51); // green
pixels[index+2] = (uint8_t)(color % 6 * 51); // blue
index += rme:
ixelFormatRGB;
empty = false;
}
}
if (!empty) {
image->SetData(pixels, true);
wxString extension = m_format == MinimapExportFormat:
ng ? "png" : "bmp";
wxBitmapType type = m_format == MinimapExportFormat:
ng ? wxBITMAP_TYPE_PNG : wxBITMAP_TYPE_BMP;
wxFileName file = wxString::Format("%d-%d-%d.%s", h, w, z, extension);
file.Normalize(wxPATH_NORM_ALL, directory);
image->SaveFile(file.GetFullPath(), type);
}
}
}
}
image->Destroy();
delete[] pixels;
return true;
}
I was looking at the RME code and got stuck.
When it retrieves the Tile, how could I write this into the image buffer?
I was thinking of an 8x image, meaning 32/4.
bool IOMinimap::exportMinimap(const std::string& directory)
{
auto& map = m_editor->getMap();
if(map.size() == 0) {
return true;
}
wxRect bounds[rme::MapLayers];
int min_z = m_floor == -1 ? 0 : m_floor;
int max_z = m_floor == -1 ? rme::MapMaxLayer : m_floor;
for (size_t z = min_z; z <= max_z; z++) {
auto& rect = bounds[z];
rect.x = rme::MapMaxWidth + 1;
rect.y = rme::MapMaxHeight + 1;
rect.width = 0;
rect.height = 0;
}
for(auto it = map.begin(); it != map.end(); ++it) {
auto tile = (*it)->get();
if(!tile || (!tile->ground && tile->items.empty())) {
continue;
}
const auto& position = tile->getPosition();
auto& rect = bounds[position.z];
if(position.x < rect.x) {
rect.x = position.x;
}
if(position.y < rect.y) {
rect.y = position.y;
}
if (position.x > rect.width) {
rect.width = position.x;
}
if (position.y > rect.height) {
rect.height = position.y;
}
}
constexpr int image_size = 1024;
constexpr int pixels_size = image_size * image_size * rme:

uint8_t* pixels = new uint8_t[pixels_size];
auto image = new wxImage(image_size, image_size, pixels, true);
for(size_t z = min_z; z <= max_z; z++) {
auto& rect = bounds[z];
if(rect.IsEmpty()) {
continue;
}
for (int h = 0; h < rme::MapMaxHeight; h += image_size) {
for (int w = 0; w < rme::MapMaxWidth; w += image_size) {
if (w < rect.x || w > rect.width || h < rect.y || h > rect.height) {
continue;
}
bool empty = true;
memset(pixels, 0, pixels_size);
int index = 0;
for (int y = 0; y < image_size; y++) {
for (int x = 0; x < image_size; x++) {
auto tile = map.getTile(w + x, h + y, z);
if(!tile || (!tile->ground && tile->items.empty())) {
index += rme:

continue;
}
uint8_t color = tile->getMiniMapColor();
pixels[index ] = (uint8_t)(static_cast<int>(color / 36) % 6 * 51); // red
pixels[index+1] = (uint8_t)(static_cast<int>(color / 6) % 6 * 51); // green
pixels[index+2] = (uint8_t)(color % 6 * 51); // blue
index += rme:

empty = false;
}
}
if (!empty) {
image->SetData(pixels, true);
wxString extension = m_format == MinimapExportFormat:

wxBitmapType type = m_format == MinimapExportFormat:

wxFileName file = wxString::Format("%d-%d-%d.%s", h, w, z, extension);
file.Normalize(wxPATH_NORM_ALL, directory);
image->SaveFile(file.GetFullPath(), type);
}
}
}
}
image->Destroy();
delete[] pixels;
return true;
}
Last edited: