You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SC2 now has 1-bit-per pixel imagedata for pathable_grid and placement_grid. SampleImageData needs to detect this and parse the image correctly. I don't know how to do a pull-request, but I think something like this works: Just replace two of the SampleImageData functions with the ones below.
inline int8_t getBit(std::string const& str, int j)
{
div_t d = div(j, 8);
unsigned char data = str[d.quot] >> (7 - d.rem);
return data & 1;
}
static bool SampleImageBit(const std::string& data, int width, int height, const Point2D& point, unsigned char& result) {
Point2DI pointI(int(point.x), int(point.y));
if (pointI.x < 0 || pointI.x >= width || pointI.y < 0 || pointI.y >= height) {
return false;
}
//const int idx = pointI.x + (height - 1 - pointI.y) * width;
const int idx = pointI.x + pointI.y * width;
result = getBit(data, idx);
return true;
}
static bool SampleImageData(const SC2APIProtocol::ImageData& data, const Point2D& point, unsigned char& result) {
if (data.bits_per_pixel() == 1)
return SampleImageBit(data.data(), data.size().x(), data.size().y(), point, result);
else if (data.bits_per_pixel() == 8)
return SampleImageData(data.data(), data.size().x(), data.size().y(), point, result);
else
return false;
}
static bool SampleImageData(const ImageData& data, const Point2D& point, unsigned char& result) {
if (data.bits_per_pixel == 1)
return SampleImageBit(data.data, data.width, data.height, point, result);
else if (data.bits_per_pixel == 8)
return SampleImageData(data.data, data.width, data.height, point, result);
else
return false;
}
The text was updated successfully, but these errors were encountered:
SC2 now has 1-bit-per pixel imagedata for pathable_grid and placement_grid.
SampleImageData
needs to detect this and parse the image correctly. I don't know how to do a pull-request, but I think something like this works: Just replace two of theSampleImageData
functions with the ones below.The text was updated successfully, but these errors were encountered: