Browse Source

image: add methods to save images and a small test program.

undefined
Sam Hocevar 10 years ago
parent
commit
d982b67aaa
13 changed files with 78 additions and 0 deletions
  1. +3
    -0
      configure.ac
  2. +8
    -0
      src/image/codec/android-image.cpp
  3. +8
    -0
      src/image/codec/dummy-image.cpp
  4. +9
    -0
      src/image/codec/gdiplus-image.cpp
  5. +9
    -0
      src/image/codec/ios-image.cpp
  6. +9
    -0
      src/image/codec/ps3-image.cpp
  7. +8
    -0
      src/image/codec/sdl-image.cpp
  8. +8
    -0
      src/image/codec/zed-image.cpp
  9. +8
    -0
      src/image/codec/zed-palette-image.cpp
  10. +1
    -0
      src/image/image-private.h
  11. +5
    -0
      src/image/image.cpp
  12. +1
    -0
      src/lol/image/image.h
  13. +1
    -0
      tools/Makefile.am

+ 3
- 0
configure.ac View File

@@ -548,6 +548,9 @@ AC_CONFIG_FILES(
AC_CONFIG_FILES(
[tools/neercs/Makefile
])
AC_CONFIG_FILES(
[tools/pimp/Makefile
])
AC_CONFIG_FILES(
[people/jnat/Makefile
people/jnat/TestProject/Makefile


+ 8
- 0
src/image/codec/android-image.cpp View File

@@ -39,6 +39,7 @@ DECLARE_IMAGE_LOADER(AndroidImageData, 100)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -108,6 +109,13 @@ bool AndroidImageData::Open(char const *path)
return true;
}

bool AndroidImageData::Save(char const *path)
{
UNUSED(path);

/* TODO: unimplemented */
}

bool AndroidImageData::Close()
{
JNIEnv *env;


+ 8
- 0
src/image/codec/dummy-image.cpp View File

@@ -28,6 +28,7 @@ DECLARE_IMAGE_LOADER(DummyImageData, 0)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -60,6 +61,13 @@ bool DummyImageData::Open(char const *path)
return true;
}

bool DummyImageData::Save(char const *path)
{
UNUSED(path);

return true;
}

bool DummyImageData::Close()
{
delete[] pixels;


+ 9
- 0
src/image/codec/gdiplus-image.cpp View File

@@ -35,6 +35,7 @@ DECLARE_IMAGE_LOADER(GdiPlusImageData, 100)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -139,6 +140,14 @@ bool GdiPlusImageData::Open(char const *path)
return true;
}

bool GdiPlusImageData::Save(char const *path)
{
UNUSED(path);

/* TODO: unimplemented */
return true;
}

bool GdiPlusImageData::Close()
{
m_bitmap->UnlockBits(&m_bdata);


+ 9
- 0
src/image/codec/ios-image.cpp View File

@@ -32,6 +32,7 @@ DECLARE_IMAGE_LOADER(IosImageData, 100)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -83,6 +84,14 @@ bool IosImageData::Open(char const *path)
return true;
}

bool IosImageData::Save(char const *path)
{
UNUSED(path);

/* TODO: unimplemented */
return true;
}

bool IosImageData::Close()
{
free(pixels);


+ 9
- 0
src/image/codec/ps3-image.cpp View File

@@ -34,6 +34,7 @@ DECLARE_IMAGE_LOADER(Ps3ImageData, 100)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -173,6 +174,14 @@ bool Ps3ImageData::Open(char const *path)
return true;
}

bool Ps3ImageData::Open(char const *path)
{
UNUSED(path);

/* TODO: unimplemented */
return true;
}

bool Ps3ImageData::Close()
{
free(pixels);


+ 8
- 0
src/image/codec/sdl-image.cpp View File

@@ -41,6 +41,7 @@ DECLARE_IMAGE_LOADER(SdlImageData, 50)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -89,6 +90,13 @@ bool SdlImageData::Open(char const *path)
return true;
}

bool SdlImageData::Save(char const *path)
{
int ret = SDL_SaveBMP(m_img, path);

return ret == 0;
}

bool SdlImageData::Close()
{
SDL_FreeSurface(m_img);


+ 8
- 0
src/image/codec/zed-image.cpp View File

@@ -29,6 +29,7 @@ DECLARE_IMAGE_LOADER(ZedImageData, 0)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -299,6 +300,13 @@ bool ZedImageData::Open(char const *path)
return true;
}

bool ZedImageData::Save(char const *path)
{
UNUSED(path);
/* FIXME: do we need to implement this? */
return true;
}

bool ZedImageData::Close()
{
delete[] m_pixels;


+ 8
- 0
src/image/codec/zed-palette-image.cpp View File

@@ -28,6 +28,7 @@ DECLARE_IMAGE_LOADER(ZedPaletteImageData, 0)
{
public:
virtual bool Open(char const *);
virtual bool Save(char const *);
virtual bool Close();

virtual uint8_t *GetData() const;
@@ -83,6 +84,13 @@ bool ZedPaletteImageData::Open(char const *path)
return true;
}

bool ZedPaletteImageData::Save(char const *path)
{
UNUSED(path);
/* FIXME: do we need to implement this? */
return true;
}

bool ZedPaletteImageData::Close()
{
delete[] m_pixels;


+ 1
- 0
src/image/image-private.h View File

@@ -81,6 +81,7 @@ public:
virtual ~ImageData() {}

virtual bool Open(char const *) = 0;
virtual bool Save(char const *) = 0;
virtual bool Close() = 0;

virtual uint8_t *GetData() const = 0;


+ 5
- 0
src/image/image.cpp View File

@@ -178,6 +178,11 @@ Image::Image()
{
}

bool Image::Save(char const *path)
{
return m_data->Save(path);
}

ivec2 Image::GetSize() const
{
return m_data->m_size;


+ 1
- 0
src/lol/image/image.h View File

@@ -31,6 +31,7 @@ public:
static Image *Load(char const *path);
static void Destroy(Image *img);

bool Save(char const *path);
ivec2 GetSize() const;
PixelFormat GetFormat() const;
uint8_t *GetData() const;


+ 1
- 0
tools/Makefile.am View File

@@ -4,6 +4,7 @@ include $(top_srcdir)/build/autotools/common.am
SUBDIRS =
SUBDIRS += lolremez
SUBDIRS += neercs
SUBDIRS += pimp
SUBDIRS += vimlol
SUBDIRS += vslol



Loading…
Cancel
Save