|
|
@@ -23,7 +23,8 @@ |
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
#include <windows.h> |
|
|
|
#include <gdiplus.h> |
|
|
|
|
|
|
|
#include <Gdiplus.h> |
|
|
|
|
|
|
|
#include "pipi.h" |
|
|
|
#include "pipi_internals.h" |
|
|
@@ -31,10 +32,9 @@ |
|
|
|
extern "C" pipi_image_t *pipi_load_gdiplus(const char *name) |
|
|
|
{ |
|
|
|
size_t len; |
|
|
|
if(mbstowcs_s(&len, NULL, 0, name, _TRUNCATE) != 0) |
|
|
|
return NULL; |
|
|
|
wchar_t *wname = new wchar_t[len]; |
|
|
|
if(mbstowcs_s(NULL, wname, len, name, _TRUNCATE) != 0) |
|
|
|
len = mbstowcs(NULL, name, 0); |
|
|
|
wchar_t *wname = new wchar_t[len + 1]; |
|
|
|
if(mbstowcs(wname, name, len + 1) != (size_t)-1) |
|
|
|
{ |
|
|
|
delete[] wname; |
|
|
|
return NULL; |
|
|
@@ -55,7 +55,7 @@ extern "C" pipi_image_t *pipi_load_gdiplus(const char *name) |
|
|
|
Gdiplus::BitmapData bdata; |
|
|
|
Gdiplus::Rect rect(0, 0, b->GetWidth(), b->GetHeight()); |
|
|
|
|
|
|
|
if(b->LockBits(&rect, Gdiplus::ImageLockModeRead, |
|
|
|
if(b->LockBits(rect, Gdiplus::ImageLockModeRead, |
|
|
|
PixelFormat32bppARGB, &bdata) != Gdiplus::Ok) |
|
|
|
{ |
|
|
|
delete b; |
|
|
@@ -109,10 +109,9 @@ extern "C" int pipi_save_gdiplus(pipi_image_t *img, const char *name) |
|
|
|
} |
|
|
|
|
|
|
|
size_t len; |
|
|
|
if(mbstowcs_s(&len, NULL, 0, name, _TRUNCATE) != 0) |
|
|
|
return NULL; |
|
|
|
wchar_t *wname = new wchar_t[len]; |
|
|
|
if(mbstowcs_s(NULL, wname, len, name, _TRUNCATE) != 0) |
|
|
|
len = mbstowcs(NULL, name, 0); |
|
|
|
wchar_t *wname = new wchar_t[len + 1]; |
|
|
|
if(mbstowcs(wname, name, len + 1) != (size_t)-1) |
|
|
|
{ |
|
|
|
delete[] wname; |
|
|
|
return -1; |
|
|
@@ -128,7 +127,7 @@ extern "C" int pipi_save_gdiplus(pipi_image_t *img, const char *name) |
|
|
|
Gdiplus::BitmapData bdata; |
|
|
|
Gdiplus::Rect rect(0, 0, img->w, img->h); |
|
|
|
|
|
|
|
if(b->LockBits(&rect, Gdiplus::ImageLockModeWrite, |
|
|
|
if(b->LockBits(rect, (unsigned int)Gdiplus::ImageLockModeWrite, |
|
|
|
PixelFormat32bppARGB, &bdata) != Gdiplus::Ok) |
|
|
|
{ |
|
|
|
delete b; |
|
|
|