summaryrefslogtreecommitdiff
path: root/DevIL/src-IL/src/il_devil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'DevIL/src-IL/src/il_devil.cpp')
-rw-r--r--DevIL/src-IL/src/il_devil.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/DevIL/src-IL/src/il_devil.cpp b/DevIL/src-IL/src/il_devil.cpp
index bfd6be00..c9eeb5d5 100644
--- a/DevIL/src-IL/src/il_devil.cpp
+++ b/DevIL/src-IL/src/il_devil.cpp
@@ -166,6 +166,81 @@ ILAPI ILboolean ILAPIENTRY ilTexImage_(ILimage *Image, ILuint Width, ILuint Heig
}
+//! Changes the current bound image to use these new dimensions (current data is destroyed, but mips, faces, layers and arrays are retained).
+/*! \param Width Specifies the new image width. This cannot be 0.
+\param Height Specifies the new image height. This cannot be 0.
+\param Depth Specifies the new image depth. This cannot be 0.
+\param NumChannels Number of channels (ex. 3 for RGB)
+\param Format Enum of the desired format. Any format values are accepted.
+\param Type Enum of the desired type. Any type values are accepted.
+\param Data Specifies data that should be copied to the new image. If this parameter is NULL, no data is copied, and the new image data consists of undefined values.
+\exception IL_ILLEGAL_OPERATION No currently bound image.
+\exception IL_INVALID_PARAM One of the parameters is incorrect, such as one of the dimensions being 0.
+\exception IL_OUT_OF_MEMORY Could not allocate enough memory.
+\return Boolean value of failure or success*/
+ILboolean ILAPIENTRY ilTexImageSurface(ILuint Width, ILuint Height, ILuint Depth, ILubyte NumChannels, ILenum Format, ILenum Type, void *Data)
+{
+ return ilTexImageSurface_(iCurImage, Width, Height, Depth, NumChannels, Format, Type, Data);
+}
+
+
+// Internal version of ilTexImageSurface.
+ILboolean ILAPIENTRY ilTexImageSurface_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data)
+{
+ ILimage* mips;
+ ILimage* next;
+ ILimage* faces;
+ ILimage* layers;
+ ILenum flags;
+ ILenum origin;
+ ILboolean retval;
+
+ if (Image == NULL) {
+ ilSetError(IL_ILLEGAL_OPERATION);
+ return IL_FALSE;
+ }
+
+ ////
+
+ // Not sure if we should be getting rid of the palette...
+ if (Image->Pal.Palette && Image->Pal.PalSize && Image->Pal.PalType != IL_PAL_NONE) {
+ ifree(Image->Pal.Palette);
+ }
+
+ if (Image->AnimList) ifree(Image->AnimList);
+ if (Image->Profile) ifree(Image->Profile);
+ if (Image->DxtcData) ifree(Image->DxtcData);
+ if (Image->Data) ifree(Image->Data);
+
+ ////
+
+ //@TODO: Also check against format?
+ /*if (Width == 0 || Height == 0 || Depth == 0 || Bpp == 0) {
+ ilSetError(IL_INVALID_PARAM);
+ return IL_FALSE;
+ }*/
+
+ mips = Image->Mipmaps;
+ next = Image->Next;
+ faces = Image->Faces;
+ layers = Image->Layers;
+ flags = Image->CubeFlags;
+ origin = Image->Origin;
+
+ retval = ilInitImage(Image, Width, Height, Depth, Bpp, Format, Type, Data);
+
+ // reset our chains
+ Image->Mipmaps = mips;
+ Image->Next = next;
+ Image->Faces = faces;
+ Image->Layers = layers;
+ Image->CubeFlags = flags;
+ Image->Origin = origin;
+
+ return retval;
+}
+
+
//! Uploads Data of the same size to replace the current image's data.
/*! \param Data New image data to update the currently bound image
\exception IL_ILLEGAL_OPERATION No currently bound image