瀏覽代碼

libpipi: make gdiplus.cpp build on older Windows versions.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3073 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
sam 16 年之前
父節點
當前提交
c30aa41e9c
共有 1 個檔案被更改,包括 10 行新增11 行删除
  1. +10
    -11
      pipi/codec/gdiplus.cpp

+ 10
- 11
pipi/codec/gdiplus.cpp 查看文件

@@ -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;


Loading…
取消
儲存