fix image reading issue
This commit is contained in:
@ -58,11 +58,11 @@ namespace LibCmo::VxMath {
|
||||
|
||||
// copy and swap data by line
|
||||
CK2::CKDWORD height = dst->GetHeight(),
|
||||
rowsize = sizeof(uint32_t) * dst->GetWidth();
|
||||
rowsize = VxImageDescEx::PixelSize * dst->GetWidth();
|
||||
for (CK2::CKDWORD row = 0; row < height; ++row) {
|
||||
std::memcpy(
|
||||
dst->GetMutableImage() + (row * rowsize),
|
||||
dst->GetImage() + ((height - row - 1) * rowsize),
|
||||
origin->GetImage() + ((height - row - 1) * rowsize),
|
||||
rowsize
|
||||
);
|
||||
}
|
||||
@ -105,7 +105,7 @@ namespace LibCmo::VxMath {
|
||||
CK2::CKDWORD pixelcount = dst_desc->GetPixelCount();
|
||||
|
||||
for (CK2::CKDWORD i = 0; i < pixelcount; ++i) {
|
||||
*pixels = (*pixels) & 0xFF000000 | AlphaValue;
|
||||
*pixels = (*pixels) & 0x00FFFFFF | (static_cast<CK2::CKDWORD>(AlphaValue) << 24);
|
||||
++pixels;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ namespace LibCmo::VxMath {
|
||||
CK2::CKDWORD pixelcount = dst_desc->GetPixelCount();
|
||||
|
||||
for (CK2::CKDWORD i = 0; i < pixelcount; ++i) {
|
||||
*pixels = (*pixels) & 0xFF000000 | (*AlphaValues);
|
||||
*pixels = (*pixels) & 0x00FFFFFF | (static_cast<CK2::CKDWORD>(*AlphaValues) << 24);
|
||||
++pixels;
|
||||
++AlphaValues;
|
||||
}
|
||||
|
@ -75,8 +75,12 @@ namespace LibCmo::VxMath {
|
||||
* Also it hold a pointer to raw image data.
|
||||
* The image data must be 32bit ARGB8888 format.
|
||||
* Thus the size of Image must be 4 * Width * Height.
|
||||
* And the image buffer must is in B, G, R, A order because little endian.
|
||||
*/
|
||||
class VxImageDescEx {
|
||||
public:
|
||||
static constexpr CK2::CKDWORD ColorFactorSize = 1u;
|
||||
static constexpr CK2::CKDWORD PixelSize = ColorFactorSize * 4u;
|
||||
public:
|
||||
VxImageDescEx() :
|
||||
m_Width(0), m_Height(0), m_Image(nullptr) {}
|
||||
@ -145,7 +149,7 @@ namespace LibCmo::VxMath {
|
||||
}
|
||||
|
||||
CK2::CKDWORD GetImageSize() const {
|
||||
return static_cast<CK2::CKDWORD>(sizeof(uint32_t) * m_Width * m_Height);
|
||||
return static_cast<CK2::CKDWORD>(PixelSize * m_Width * m_Height);
|
||||
}
|
||||
const CK2::CKBYTE* GetImage() const {
|
||||
return m_Image;
|
||||
|
Reference in New Issue
Block a user