Преглед на файлове

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 <string.h>


#include <windows.h> #include <windows.h>
#include <gdiplus.h>

#include <Gdiplus.h>


#include "pipi.h" #include "pipi.h"
#include "pipi_internals.h" #include "pipi_internals.h"
@@ -31,10 +32,9 @@
extern "C" pipi_image_t *pipi_load_gdiplus(const char *name) extern "C" pipi_image_t *pipi_load_gdiplus(const char *name)
{ {
size_t len; 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; delete[] wname;
return NULL; return NULL;
@@ -55,7 +55,7 @@ extern "C" pipi_image_t *pipi_load_gdiplus(const char *name)
Gdiplus::BitmapData bdata; Gdiplus::BitmapData bdata;
Gdiplus::Rect rect(0, 0, b->GetWidth(), b->GetHeight()); 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) PixelFormat32bppARGB, &bdata) != Gdiplus::Ok)
{ {
delete b; delete b;
@@ -109,10 +109,9 @@ extern "C" int pipi_save_gdiplus(pipi_image_t *img, const char *name)
} }


size_t len; 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; delete[] wname;
return -1; return -1;
@@ -128,7 +127,7 @@ extern "C" int pipi_save_gdiplus(pipi_image_t *img, const char *name)
Gdiplus::BitmapData bdata; Gdiplus::BitmapData bdata;
Gdiplus::Rect rect(0, 0, img->w, img->h); 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) PixelFormat32bppARGB, &bdata) != Gdiplus::Ok)
{ {
delete b; delete b;


Зареждане…
Отказ
Запис