return false;
}
- file.Write(bmpFileHeader, sizeof(bmpFileHeader));
- file.Write(bmpDibHeader, sizeof(bmpDibHeader));
+ {
+ result r1 = file.Write(bmpFileHeader, sizeof(bmpFileHeader));
+ result r2 = file.Write(bmpDibHeader, sizeof(bmpDibHeader));
+
+ if (r1 != E_SUCCESS || r2 != E_SUCCESS)
+ {
+ return false;
+ }
+ }
{
typedef unsigned long SourPixel;
++pSour32;
}
- file.Write(lineBuffer.Get(), dstPitch);
+ if (file.Write(lineBuffer.Get(), dstPitch) != E_SUCCESS)
+ {
+ return false;
+ }
}
}
return succeeded;
}
+////////////////////////////////////////////////////////////////////////////////
+
+bool ConvertToNonpremultiplied(Bitmap& bitmap)
+{
+ BufferInfo bi;
+
+ if (bitmap.Lock(bi) != E_SUCCESS)
+ {
+ return false;
+ }
+
+ bool result = false;
+
+ do
+ {
+ if (bi.bitsPerPixel != 32)
+ {
+ result = true;
+ break;
+ }
+
+ //if (!bitmap->isPremultiplied)
+ // return;
+
+ typedef unsigned long DestPixel;
+
+ DestPixel* p = static_cast<DestPixel*>(bi.pPixels);
+ long paddingBytes = bi.pitch - bi.width * bi.bitsPerPixel / 8;
+
+ for (int y = 0; y < bi.height; y++)
+ {
+ for (int x = 0; x < bi.width; x++)
+ {
+ DestPixel a = (*p >> 24);
+
+ if (a > 0 && a < 254)
+ {
+ a += (a >> 7);
+
+ DestPixel r = (*p >> 8) & 0x0000FF00;
+ r = r / a;
+ r = (r > 255) ? 255 : r;
+
+ DestPixel g = (*p >> 0) & 0x0000FF00;
+ g = g / a;
+ g = (g > 255) ? 255 : g;
+
+ DestPixel b = (*p << 8) & 0x0000FF00;
+ b = b / a;
+ b = (b > 255) ? 255 : b;
+
+ *p = (*p & 0xFF000000) | (r << 16) | (g << 8) | b;
+ }
+
+ p++;
+ }
+
+ p = reinterpret_cast<DestPixel*>(reinterpret_cast<unsigned char*>(p) + paddingBytes);
+ }
+
+ result = true;
+
+ } while (0);
+
+ bitmap.Unlock();
+
+ return result;
+}
+
}}} // Tizen::Graphics::_Farm