Skip to content

Commit

Permalink
- Added ilTexImageSurface from gscept@122565d
Browse files Browse the repository at this point in the history
  • Loading branch information
DentonW committed Jan 1, 2017
1 parent f9d385e commit 1e02ea2
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 14 deletions.
14 changes: 8 additions & 6 deletions DevIL/TODO
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Bugs:

By next release:

- https://www.cvedetails.com/vulnerability-list/vendor_id-8981/product_id-15876/version_id-67926/Devil-Developers-Image-Library-1.7.4.html
- NVTT.dll as a delay-loaded DLL.
- Update docs with next DXT code, new mipmap/cubemap access, new SaveL code.
- Update DevIL website with file formats (psd-saving, etc.).
Expand Down Expand Up @@ -167,6 +168,8 @@ More involved:


Lots of work:
- Go through forks on GitHub to see what needs to be included in the main release
- Thread safe version: look at https://github.com/gscept/DevIL/commit/a8bbbb934344237c362a15164b536f97f54d2cd8
- Linux Unicode support is partially broken.
- Write own .exr routines.
- Native WDP support
Expand All @@ -175,15 +178,14 @@ Lots of work:
- Give estimates for buffer sizes for ilSaveL.
- MNG saving
- Metadata
- Thread safe version
- Add flag for determining whether DDS data is outdated.
- TIFF saving to file streams and lumps
- Use fseek/ftell 64-bit?
- Check for any external library pointers that are assumed to be 32-bit.
- Possibly make palettes always 768 (or 1024) bytes so that it is not possible to access outside by bad data?
- Add padding options, so that each line could be DWORD-padded, for instance.
- Add dithering.
- Work on making DevIL more stable. There's probably a few places where I don't check the return value of ilNewImage, for instance.
- Work on making DevIL more stable. There's probably a few places where I don't check the return value of ilNewImage, for instance.
- Add support for callbacks so that users can create progress meters for loading and saving in their applications. We could extend this idea further and allow cancellation of loading/saving images.
- global use of restricted pointers where available (for now only il_bmp.{c,h} uses it)
- iluScaleColours is BUGGED, doesn't handle the image with the correct type! more Bpc (except luminance and paletted one)
Expand All @@ -197,17 +199,17 @@ Lots of work:
- Finish support for regions in ILU.
- Add support for regions in IL. This could be used to save only a specific portion of an image.
- Add support for user-defined filters (possibly of a user-defined size).
- Add more filters. Some sites to look at are http://www.jasonwaltman.com/thesis/introduction.html http://www.dai.ed.ac.uk/CVonline/transf.htm http://www.fortunecity.com/lavendar/kane/39/ffpg.htm and http://www.opengl.org/developers/documentation/Version1.2/1.2specs/convolution_border_modes.txt . The last link describes ways to handle borders for the convolution filters. It might be worthwhile to allow these kinds of options.
- Add more filters. Some sites to look at are http://www.jasonwaltman.com/thesis/introduction.html http://www.dai.ed.ac.uk/CVonline/transf.htm http://www.fortunecity.com/lavendar/kane/39/ffpg.htm and http://www.opengl.org/developers/documentation/Version1.2/1.2specs/convolution_border_modes.txt . The last link describes ways to handle borders for the convolution filters. It might be worthwhile to allow these kinds of options.
- Possibly add support for other colour spaces besides RGB (CMYK, YUV, etc.)
- Implement a scripting "language" with LUA for ILU. This way, people can generate scripts to run a certain set of filters on all images.
- Implement a scripting "language" with LUA for ILU. This way, people can generate scripts to run a certain set of filters on all images.
- Look at other rescaling algorithms:
http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0guide/Geom-image-manip.doc.html
http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0guide/Geom-image-manip.doc.html#55431
http://www.npac.syr.edu/projects/nasa/MILOJE/final/node36.html
http://www.ultranet.com/~aramini/design.html
- ilKeyColor ilAddKey...
- Find a way to make the filters (especially the convolution filters) work in three dimensions.
- Make better versions of the DevIL ports of the NeHe tutorials. Several of the tutorials don't call ilInit, for instance.
- Make better versions of the DevIL ports of the NeHe tutorials. Several of the tutorials don't call ilInit, for instance.
- Change parameters of iread to use ILsizei.
- Make sure all bugs in bug tracker are squashed.

Expand All @@ -217,7 +219,7 @@ Questions:
- Possibly readd VC6 projects?
- Add BeOS support back in?
- Create Dev-C++/MingW/Cygwin .a files for releases?
- Does ilIsValidTga generate an unncessary IL_INVALID_EXTENSION error?
- Does ilIsValidTga generate an unnecessary IL_INVALID_EXTENSION error?
- Why is IL_HALF even used in ilut_directx9.c?
- Fix problems loading .dds files on Big Endian machines (still a problem or not?)
- Should we be calculating DXT endpoints before converting data to 565 format?
Expand Down
1 change: 1 addition & 0 deletions DevIL/include/IL/devil_internal_exports.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ ILAPI ILimage* ILAPIENTRY ilNewImageFull (ILuint Width, ILuint Height, ILuint
ILAPI ILboolean ILAPIENTRY ilInitImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilResizeImage (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILubyte Bpc);
ILAPI ILboolean ILAPIENTRY ilTexImage_ (ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilTexImageSurface_(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data);
ILAPI ILboolean ILAPIENTRY ilTexSubImage_ (ILimage *Image, void *Data);
ILAPI void* ILAPIENTRY ilConvertBuffer (ILuint SizeOfData, ILenum SrcFormat, ILenum DestFormat, ILenum SrcType, ILenum DestType, ILpal *SrcPal, void *Buffer);
ILAPI ILimage* ILAPIENTRY iConvertImage (ILimage *Image, ILenum DestFormat, ILenum DestType);
Expand Down
1 change: 1 addition & 0 deletions DevIL/src-IL/msvc/il.def
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ ilShutDown
ilSurfaceToDxtcData
ilTexImage
ilTexImageDxtc
ilTexImageSurface
ilTypeFromExt
ilTypeFunc
ilLoadData
Expand Down
10 changes: 5 additions & 5 deletions DevIL/src-IL/src/il_dds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2028,23 +2028,23 @@ ILAPI ILboolean ILAPIENTRY ilDxtcDataToImage()
ILAPI ILboolean ILAPIENTRY ilSurfaceToDxtcData(ILenum Format)
{
ILuint Size;
void* Data;
ILubyte* Data;
ilFreeSurfaceDxtcData();

Size = ilGetDXTCData(NULL, 0, Format);
if (Size == 0) {
return IL_FALSE;
}

Data = ialloc(Size);
Data = (ILubyte*)ialloc(Size);

if (Data == NULL)
return IL_FALSE;

ilGetDXTCData(Data, Size, Format);
ilGetDXTCData((void*)Data, Size, Format);

//These have to be after the call to ilGetDXTCData()
iCurImage->DxtcData = (ILubyte*)Data;
iCurImage->DxtcData = Data;
iCurImage->DxtcFormat = Format;
iCurImage->DxtcSize = Size;

Expand Down Expand Up @@ -2139,7 +2139,7 @@ ILAPI ILboolean ILAPIENTRY ilTexImageDxtc(ILint w, ILint h, ILint d, ILenum DxtF
DataSize = yBlocks * LineSize * d;

Image->DxtcFormat = DxtFormat;
Image->DxtcSize = DataSize;
Image->DxtcSize = DataSize;
Image->DxtcData = (ILubyte*)ialloc(DataSize);

if (Image->DxtcData == NULL) {
Expand Down
75 changes: 75 additions & 0 deletions DevIL/src-IL/src/il_devil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions DevIL/src-IL/src/il_hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,8 @@ ILboolean iGetHdrHead(HDRHEADER *Header)
if (iread(&a, 1, 1) != 1)
return IL_FALSE;
while (a != '\n') {
if (count >= 80) { // Line shouldn't be this long at all.
ilSetError(IL_INVALID_FILE_HEADER);
if (count >= 80) // Line shouldn't be this long at all.
return IL_FALSE;
}
buff[count] = a;
if (iread(&a, 1, 1) != 1)
return IL_FALSE;
Expand Down

0 comments on commit 1e02ea2

Please sign in to comment.