Browse Source

* oops, forgot to commit #ifdef fixes.

git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/pwntcha/trunk@442 92316355-f0b4-4df1-b90c-862c8a59935f
master
sam 20 years ago
parent
commit
2775834444
1 changed files with 19 additions and 11 deletions
  1. +19
    -11
      src/image.c

+ 19
- 11
src/image.c View File

@@ -15,11 +15,13 @@
#include "config.h" #include "config.h"
#include "common.h" #include "common.h"


#if defined(WIN32)
#if defined(HAVE_IL_H)
# error "DevIL routines not implemented yet"
#elif defined(HAVE_OLECTL_H)
# include <windows.h> # include <windows.h>
# include <ocidl.h> # include <ocidl.h>
# include <olectl.h> # include <olectl.h>
BOOL oleload(LPCTSTR name, LPPICTURE* pic);
static BOOL oleload(LPCTSTR name, LPPICTURE* pic);
struct priv struct priv
{ {
HBITMAP bitmap; HBITMAP bitmap;
@@ -39,7 +41,8 @@ struct priv
struct image *image_load(const char *name) struct image *image_load(const char *name)
{ {
struct image *img; struct image *img;
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)
struct priv *priv = malloc(sizeof(struct priv)); struct priv *priv = malloc(sizeof(struct priv));
LPPICTURE pic = NULL; LPPICTURE pic = NULL;
HDC dc; HDC dc;
@@ -57,7 +60,7 @@ struct image *image_load(const char *name)
if(!priv) if(!priv)
return NULL; return NULL;


#if defined(WIN32)
#if defined(HAVE_OLECTL_H)
if(!oleload((LPCTSTR)name, &pic)) if(!oleload((LPCTSTR)name, &pic))
{ {
free(priv); free(priv);
@@ -118,7 +121,8 @@ struct image *image_load(const char *name)
#endif #endif


img = (struct image *)malloc(sizeof(struct image)); img = (struct image *)malloc(sizeof(struct image));
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)
img->width = width; img->width = width;
img->height = height; img->height = height;
img->pitch = 3 * width; img->pitch = 3 * width;
@@ -152,7 +156,8 @@ struct image *image_load(const char *name)
struct image *image_new(int width, int height) struct image *image_new(int width, int height)
{ {
struct image *img; struct image *img;
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)
struct priv *priv = malloc(sizeof(struct priv)); struct priv *priv = malloc(sizeof(struct priv));
HDC dc; HDC dc;
void *data = NULL; void *data = NULL;
@@ -182,7 +187,8 @@ struct image *image_new(int width, int height)
return NULL; return NULL;


img = (struct image *)malloc(sizeof(struct image)); img = (struct image *)malloc(sizeof(struct image));
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)
dc = CreateCompatibleDC(NULL); dc = CreateCompatibleDC(NULL);
if(GetDeviceCaps(dc, BITSPIXEL) < 24) if(GetDeviceCaps(dc, BITSPIXEL) < 24)
{ {
@@ -232,7 +238,8 @@ struct image *image_new(int width, int height)


void image_free(struct image *img) void image_free(struct image *img)
{ {
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)
struct priv *priv = img->priv; struct priv *priv = img->priv;
DeleteObject(priv->bitmap); DeleteObject(priv->bitmap);
free(img->priv); free(img->priv);
@@ -252,7 +259,8 @@ void image_free(struct image *img)


void image_save(struct image *img, const char *name) void image_save(struct image *img, const char *name)
{ {
#if defined(WIN32)
#if defined(HAVE_IL_H)
#elif defined(HAVE_OLECTL_H)


#elif defined(HAVE_SDL_IMAGE_H) #elif defined(HAVE_SDL_IMAGE_H)
SDL_SaveBMP(img->priv, name); SDL_SaveBMP(img->priv, name);
@@ -306,8 +314,8 @@ int setpixel(struct image *img, int x, int y, int r, int g, int b)
return 0; return 0;
} }


#if defined(WIN32)
BOOL oleload(LPCTSTR name, LPPICTURE* pic)
#if defined(HAVE_OLECTL_H)
static BOOL oleload(LPCTSTR name, LPPICTURE* pic)
{ {
HRESULT ret; HRESULT ret;
HANDLE h; HANDLE h;


Loading…
Cancel
Save