copyPixels alpha position fix (resolve #1707)
This commit is contained in:
@@ -48,6 +48,7 @@ namespace lime {
|
||||
ImageDataView (Image* image, Rectangle* rect);
|
||||
|
||||
void Clip (int x, int y, int width, int height);
|
||||
bool HasRow (int y);
|
||||
int Row (int y);
|
||||
|
||||
int x;
|
||||
|
||||
@@ -211,18 +211,21 @@ namespace lime {
|
||||
PixelFormat alphaFormat = alphaImage->buffer->format;
|
||||
bool alphaPremultiplied = alphaImage->buffer->premultiplied;
|
||||
|
||||
Rectangle alphaRect = Rectangle (alphaPoint->x, alphaPoint->y, destView.width, destView.height);
|
||||
Rectangle alphaRect = Rectangle (alphaPoint->x, alphaPoint->y, alphaImage->width, alphaImage->height);
|
||||
ImageDataView alphaView = ImageDataView (alphaImage, &alphaRect);
|
||||
int alphaPosition;
|
||||
RGBA alphaPixel;
|
||||
int alphaOffsetY = alphaView.y + sourceView.y;
|
||||
|
||||
if (blend) {
|
||||
|
||||
for (int y = 0; y < destView.height; y++) {
|
||||
|
||||
if (!alphaView.HasRow (y + alphaOffsetY)) continue;
|
||||
|
||||
sourcePosition = sourceView.Row (y);
|
||||
destPosition = destView.Row (y);
|
||||
alphaPosition = alphaView.Row (y);
|
||||
alphaPosition = alphaView.Row (y + alphaOffsetY);
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
@@ -259,9 +262,11 @@ namespace lime {
|
||||
|
||||
for (int y = 0; y < destView.height; y++) {
|
||||
|
||||
if (!alphaView.HasRow (y + alphaOffsetY)) continue;
|
||||
|
||||
sourcePosition = sourceView.Row (y);
|
||||
destPosition = destView.Row (y);
|
||||
alphaPosition = alphaView.Row (y);
|
||||
alphaPosition = alphaView.Row (y + alphaOffsetY);
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
@@ -845,6 +850,13 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
inline bool ImageDataView::HasRow (int y) {
|
||||
|
||||
return (y >= 0 && y < height);
|
||||
|
||||
}
|
||||
|
||||
|
||||
inline int ImageDataView::Row (int y) {
|
||||
|
||||
return offset + stride * y;
|
||||
|
||||
Reference in New Issue
Block a user