@@ -23,6 +23,7 @@
|
||||
#include <system/CFFIPointer.h>
|
||||
#include <system/Clipboard.h>
|
||||
#include <system/ClipboardEvent.h>
|
||||
#include <system/Endian.h>
|
||||
#include <system/JNI.h>
|
||||
#include <system/Locale.h>
|
||||
#include <system/SensorEvent.h>
|
||||
@@ -978,13 +979,14 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void lime_image_data_util_set_pixels (value image, value rect, value bytes, int offset, int format) {
|
||||
void lime_image_data_util_set_pixels (value image, value rect, value bytes, int offset, int format, int endian) {
|
||||
|
||||
Image _image = Image (image);
|
||||
Rectangle _rect = Rectangle (rect);
|
||||
Bytes _bytes (bytes);
|
||||
PixelFormat _format = (PixelFormat)format;
|
||||
ImageDataUtil::SetPixels (&_image, &_rect, &_bytes, offset, _format);
|
||||
Endian _endian = (Endian)endian;
|
||||
ImageDataUtil::SetPixels (&_image, &_rect, &_bytes, offset, _format, _endian);
|
||||
|
||||
}
|
||||
|
||||
@@ -1847,7 +1849,7 @@ namespace lime {
|
||||
DEFINE_PRIME1v (lime_image_data_util_multiply_alpha);
|
||||
DEFINE_PRIME4v (lime_image_data_util_resize);
|
||||
DEFINE_PRIME2v (lime_image_data_util_set_format);
|
||||
DEFINE_PRIME5v (lime_image_data_util_set_pixels);
|
||||
DEFINE_PRIME6v (lime_image_data_util_set_pixels);
|
||||
DEFINE_PRIME12 (lime_image_data_util_threshold);
|
||||
DEFINE_PRIME1v (lime_image_data_util_unmultiply_alpha);
|
||||
DEFINE_PRIME4 (lime_image_encode);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include <graphics/utils/ImageDataUtil.h>
|
||||
#include <math/color/RGBA.h>
|
||||
#include <system/System.h>
|
||||
#include <utils/QuickVec.h>
|
||||
#include <math.h>
|
||||
|
||||
@@ -38,7 +37,7 @@ namespace lime {
|
||||
|
||||
offset = row + (x * 4);
|
||||
|
||||
pixel.ReadUInt8 (data, offset, format, premultiplied);
|
||||
pixel.ReadUInt8 (data, offset, format, premultiplied, BIG_ENDIAN);
|
||||
pixel.Set (redTable[pixel.r], greenTable[pixel.g], blueTable[pixel.b], alphaTable[pixel.a]);
|
||||
pixel.WriteUInt8 (data, offset, format, premultiplied);
|
||||
|
||||
@@ -74,8 +73,8 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
srcPixel.ReadUInt8 (srcData, srcPosition, srcFormat, srcPremultiplied);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
srcPixel.ReadUInt8 (srcData, srcPosition, srcFormat, srcPremultiplied, BIG_ENDIAN);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied, BIG_ENDIAN);
|
||||
|
||||
switch (srcChannel) {
|
||||
|
||||
@@ -144,8 +143,8 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied, BIG_ENDIAN);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied, BIG_ENDIAN);
|
||||
|
||||
sourceAlpha = sourcePixel.a / 255.0;
|
||||
destAlpha = destPixel.a / 255.0;
|
||||
@@ -194,7 +193,7 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied);
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied, BIG_ENDIAN);
|
||||
sourcePixel.WriteUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
|
||||
sourcePosition += 4;
|
||||
@@ -228,9 +227,9 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
alphaPixel.ReadUInt8 (alphaData, alphaPosition, alphaFormat, false);
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied, BIG_ENDIAN);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied, BIG_ENDIAN);
|
||||
alphaPixel.ReadUInt8 (alphaData, alphaPosition, alphaFormat, false, BIG_ENDIAN);
|
||||
|
||||
sourceAlpha = (alphaPixel.a / 255.0) * (sourcePixel.a / 255.0);
|
||||
|
||||
@@ -267,8 +266,8 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied);
|
||||
alphaPixel.ReadUInt8 (alphaData, alphaPosition, alphaFormat, false);
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied, BIG_ENDIAN);
|
||||
alphaPixel.ReadUInt8 (alphaData, alphaPosition, alphaFormat, false, BIG_ENDIAN);
|
||||
|
||||
sourcePixel.a = int (0.5 + (sourcePixel.a * (alphaPixel.a / 255.0)));
|
||||
sourcePixel.WriteUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
@@ -338,7 +337,7 @@ namespace lime {
|
||||
if (premultiplied) fillColor.MultiplyAlpha ();
|
||||
|
||||
RGBA hitColor;
|
||||
hitColor.ReadUInt8 (data, ((y + image->offsetY) * (image->buffer->width * 4)) + ((x + image->offsetX) * 4), format, premultiplied);
|
||||
hitColor.ReadUInt8 (data, ((y + image->offsetY) * (image->buffer->width * 4)) + ((x + image->offsetX) * 4), format, premultiplied, BIG_ENDIAN);
|
||||
|
||||
if (!image->buffer->transparent) {
|
||||
|
||||
@@ -381,7 +380,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
nextPointOffset = (nextPointY * image->width + nextPointX) * 4;
|
||||
readColor.ReadUInt8 (data, nextPointOffset, format, premultiplied);
|
||||
readColor.ReadUInt8 (data, nextPointOffset, format, premultiplied, BIG_ENDIAN);
|
||||
|
||||
if (readColor == hitColor) {
|
||||
|
||||
@@ -420,7 +419,7 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < dataView.width; x++) {
|
||||
|
||||
pixel.ReadUInt8 (data, position, sourceFormat, premultiplied);
|
||||
pixel.ReadUInt8 (data, position, sourceFormat, premultiplied, BIG_ENDIAN);
|
||||
pixel.WriteUInt8 (destData, destPosition, format, false);
|
||||
|
||||
position += 4;
|
||||
@@ -456,8 +455,8 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied);
|
||||
sourcePixel.ReadUInt8 (sourceData, sourcePosition, sourceFormat, sourcePremultiplied, BIG_ENDIAN);
|
||||
destPixel.ReadUInt8 (destData, destPosition, destFormat, destPremultiplied, BIG_ENDIAN);
|
||||
|
||||
destPixel.r = int (((sourcePixel.r * redMultiplier) + (destPixel.r * (256 - redMultiplier))) / 256);
|
||||
destPixel.g = int (((sourcePixel.g * greenMultiplier) + (destPixel.g * (256 - greenMultiplier))) / 256);
|
||||
@@ -485,7 +484,7 @@ namespace lime {
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
pixel.ReadUInt8 (data, i * 4, format, false);
|
||||
pixel.ReadUInt8 (data, i * 4, format, false, BIG_ENDIAN);
|
||||
pixel.WriteUInt8 (data, i * 4, format, true);
|
||||
|
||||
}
|
||||
@@ -634,7 +633,7 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
void ImageDataUtil::SetPixels (Image* image, Rectangle* rect, Bytes* bytes, int offset, PixelFormat format) {
|
||||
void ImageDataUtil::SetPixels (Image* image, Rectangle* rect, Bytes* bytes, int offset, PixelFormat format, Endian endian) {
|
||||
|
||||
uint8_t* data = (uint8_t*)image->buffer->data->Data ();
|
||||
PixelFormat sourceFormat = image->buffer->format;
|
||||
@@ -654,7 +653,7 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < dataView.width; x++) {
|
||||
|
||||
pixel.ReadUInt8 (byteArray, srcPosition, format, false);
|
||||
pixel.ReadUInt8 (byteArray, srcPosition, format, false, endian);
|
||||
if (!transparent) pixel.a = 0xFF;
|
||||
pixel.WriteUInt8 (data, row + (x * 4), sourceFormat, premultiplied);
|
||||
|
||||
@@ -752,7 +751,7 @@ namespace lime {
|
||||
|
||||
for (int x = 0; x < destView.width; x++) {
|
||||
|
||||
srcPixel.ReadUInt8 (srcData, srcPosition, srcFormat, srcPremultiplied);
|
||||
srcPixel.ReadUInt8 (srcData, srcPosition, srcFormat, srcPremultiplied, BIG_ENDIAN);
|
||||
|
||||
pixelMask = srcPixel.Get () & mask;
|
||||
|
||||
@@ -801,7 +800,7 @@ namespace lime {
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
|
||||
pixel.ReadUInt8 (data, i * 4, format, true);
|
||||
pixel.ReadUInt8 (data, i * 4, format, true, BIG_ENDIAN);
|
||||
pixel.WriteUInt8 (data, i * 4, format, false);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user