Fix BitmapData issues for HL

This commit is contained in:
Joshua Granick
2019-04-10 16:26:03 -07:00
parent 29f9509f9d
commit 40ccd22c79
5 changed files with 33 additions and 22 deletions

View File

@@ -19,7 +19,7 @@ namespace lime {
int offsetX;
int offsetY;
Rectangle* rect;
/*ImageType*/ int type;
venum* type;
int version;
int width;
double x;

View File

@@ -63,7 +63,7 @@ namespace lime {
int byteOffset;
Image* image;
Rectangle* rect;
Rectangle rect;
int stride;

View File

@@ -16,6 +16,7 @@ namespace lime {
double x;
double y;
Rectangle ();
Rectangle (double x, double y, double width, double height);
Rectangle (value rect);

View File

@@ -19,6 +19,7 @@ namespace lime {
bool premultiplied = image->buffer->premultiplied;
uint8_t* data = (uint8_t*)image->buffer->data->buffer->b;
Rectangle* _rect = (Rectangle*)(image->type);
ImageDataView dataView = ImageDataView (image, rect);
colorMatrix->GetAlphaTable (alphaTable);
@@ -811,14 +812,14 @@ namespace lime {
ImageDataView::ImageDataView (Image* image, Rectangle* rect) {
this->image = image;
this->rect = Rectangle(rect->x, rect->y, rect->width, rect->height);
if (rect->x < 0) rect->x = 0;
if (rect->y < 0) rect->y = 0;
if (rect->x + rect->width > image->width) rect->width = image->width - rect->x;
if (rect->y + rect->height > image->height) rect->height = image->height - rect->y;
if (rect->width < 0) rect->width = 0;
if (rect->height < 0) rect->height = 0;
this->rect = rect;
if (this->rect.x < 0) this->rect.x = 0;
if (this->rect.y < 0) this->rect.y = 0;
if (this->rect.x + this->rect.width > image->width) this->rect.width = image->width - this->rect.x;
if (this->rect.y + this->rect.height > image->height) this->rect.height = image->height - this->rect.y;
if (this->rect.width < 0) this->rect.width = 0;
if (this->rect.height < 0) this->rect.height = 0;
stride = image->buffer->Stride ();
@@ -830,7 +831,7 @@ namespace lime {
void ImageDataView::Clip (int x, int y, int width, int height) {
rect->Contract (x, y, width, height);
rect.Contract (x, y, width, height);
__Update ();
}
@@ -847,25 +848,25 @@ namespace lime {
if (x < 0) {
rect->x += x;
if (rect->x < 0) rect->x = 0;
rect.x += x;
if (rect.x < 0) rect.x = 0;
} else {
rect->x += x;
rect->width -= x;
rect.x += x;
rect.width -= x;
}
if (y < 0) {
rect->y += y;
if (rect->y < 0) rect->y = 0;
rect.y += y;
if (rect.y < 0) rect.y = 0;
} else {
rect->y += y;
rect->height -= y;
rect.y += y;
rect.height -= y;
}
@@ -883,10 +884,10 @@ namespace lime {
inline void ImageDataView::__Update () {
this->x = (int) ceil (rect->x);
this->y = (int) ceil (rect->y);
this->width = (int) floor (rect->width);
this->height = (int) floor (rect->height);
this->x = (int) ceil (rect.x);
this->y = (int) ceil (rect.y);
this->width = (int) floor (rect.width);
this->height = (int) floor (rect.height);
byteOffset = (stride * (this->y + image->offsetY)) + ((this->x + image->offsetX) * 4);
}

View File

@@ -11,6 +11,15 @@ namespace lime {
static bool init = false;
Rectangle::Rectangle () {
t = 0;
SetTo (0, 0, 0, 0);
}
Rectangle::Rectangle (double x, double y, double width, double height) {
t = 0;