MCPcopy Create free account
hub / github.com/DentonW/DevIL / ILAPIENTRY ilModAlpha

Function ILAPIENTRY ilModAlpha

DevIL/src-IL/src/il_manip.cpp:1046–1123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044}
1045
1046void ILAPIENTRY ilModAlpha(ILdouble AlphaValue)
1047{
1048 ILuint AlphaOff = 0;
1049 ILboolean ret = IL_FALSE;
1050 ILuint i,j,Size;
1051
1052 union {
1053 ILubyte alpha_byte;
1054 ILushort alpha_short;
1055 ILuint alpha_int;
1056 ILfloat alpha_float;
1057 ILdouble alpha_double;
1058 } Alpha;
1059
1060
1061 if (iCurImage == NULL) {
1062 ilSetError(IL_ILLEGAL_OPERATION);
1063 return;
1064 }
1065
1066 switch (iCurImage->Format)
1067 {
1068 case IL_RGB:
1069 ret = ilConvertImage(IL_RGBA,iCurImage->Type);
1070 AlphaOff = 4;
1071 break;
1072 case IL_BGR:
1073 ret = ilConvertImage(IL_BGRA,iCurImage->Type);
1074 AlphaOff = 4;
1075 break;
1076 case IL_LUMINANCE:
1077 ret = ilConvertImage(IL_LUMINANCE_ALPHA,iCurImage->Type);
1078 AlphaOff = 2;
1079 break;
1080 case IL_COLOUR_INDEX:
1081 ret = ilConvertImage(IL_RGBA,iCurImage->Type);
1082 AlphaOff = 4;
1083 break;
1084 }
1085 Size = iCurImage->Width * iCurImage->Height * iCurImage->Depth * iCurImage->Bpp;
1086
1087 if (!ret)
1088 return;
1089
1090 switch (iCurImage->Type)
1091 {
1092 case IL_BYTE:
1093 case IL_UNSIGNED_BYTE:
1094 Alpha.alpha_byte = (ILubyte)(AlphaValue * 0x000000FF + .5);
1095 for (i = AlphaOff-1, j = 0; i < Size; i += AlphaOff, j++)
1096 iCurImage->Data[i] = Alpha.alpha_byte;
1097 break;
1098 case IL_SHORT:
1099 case IL_UNSIGNED_SHORT:
1100 Alpha.alpha_short = (ILushort)(AlphaValue * 0x0000FFFF + .5);
1101 for (i = AlphaOff-1, j = 0; i < Size; i += AlphaOff, j++)
1102 ((ILushort*)iCurImage->Data)[i] = Alpha.alpha_short;
1103 break;

Callers

nothing calls this directly

Calls 1

ilSetErrorFunction · 0.85

Tested by

no test coverage detected