Clean up the blit row code and add a Haxe alternative
This commit is contained in:
@@ -20,7 +20,6 @@ namespace lime {
|
||||
~ImageBuffer ();
|
||||
|
||||
void Blit (const unsigned char *data, int x, int y, int width, int height);
|
||||
void BlitRow (const unsigned char *data, int sourcePosition, int destPosition, int sourceW);
|
||||
void Resize (int width, int height, int bitsPerPixel = 32);
|
||||
int Stride ();
|
||||
value Value ();
|
||||
|
||||
@@ -94,19 +94,7 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImageBuffer::BlitRow (const unsigned char *data, int sourcePosition, int destPosition, int sourceW) {
|
||||
|
||||
int stride = (sourceW * (((bitsPerPixel + 3) & ~0x3) >> 3));
|
||||
|
||||
unsigned char *bytes = this->data->Data ();
|
||||
|
||||
memcpy (&bytes[destPosition], &data[sourcePosition], stride);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ImageBuffer::Resize (int width, int height, int bitsPerPixel) {
|
||||
|
||||
@@ -124,26 +124,23 @@ namespace lime {
|
||||
|
||||
bool sourcePremultiplied = sourceImage->buffer->premultiplied;
|
||||
bool destPremultiplied = image->buffer->premultiplied;
|
||||
int sourceBitsPerPixel = sourceImage->buffer->bitsPerPixel;
|
||||
int destBitsPerPixel = image->buffer->bitsPerPixel;
|
||||
|
||||
if (!mergeAlpha || !sourceImage->buffer->transparent) {
|
||||
|
||||
if(sourceFormat == destFormat && sourcePremultiplied == destPremultiplied) {
|
||||
if (sourceFormat == destFormat && sourcePremultiplied == destPremultiplied && sourceBitsPerPixel == destBitsPerPixel) {
|
||||
|
||||
if (false == (destView.x < 0 || destView.x + sourceView.width > image->width || destView.y < 0 || destView.y + destView.height > image->height)) {
|
||||
for (int y = 0; y < destView.height; y++) {
|
||||
|
||||
for (int y = 0; y < destView.height; y++) {
|
||||
|
||||
sourcePosition = sourceView.Row (y);
|
||||
destPosition = destView.Row (y);
|
||||
|
||||
image->buffer->BlitRow(sourceData, sourcePosition, destPosition, sourceView.width);
|
||||
|
||||
}
|
||||
sourcePosition = sourceView.Row (y);
|
||||
destPosition = destView.Row (y);
|
||||
|
||||
memcpy (&destData[destPosition], &sourceData[sourcePosition], destView.width * destBitsPerPixel);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
|
||||
for (int y = 0; y < destView.height; y++) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user