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

Function ILAPIENTRY iluEnlargeCanvas

DevIL/src-ILU/src/ilu_manip.cpp:113–231  ·  view source on GitHub ↗

Enlarges the canvas

Source from the content-addressed store, hash-verified

111
112//! Enlarges the canvas
113ILboolean ILAPIENTRY iluEnlargeCanvas(ILuint Width, ILuint Height, ILuint Depth)
114{
115 ILubyte *Data/*, Clear[4]*/;
116 ILuint x, y, z, OldBps, OldH, OldD, OldPlane, AddX, AddY;
117 ILenum Origin;
118
119 iluCurImage = ilGetCurImage();
120 if (iluCurImage == NULL) {
121 ilSetError(ILU_ILLEGAL_OPERATION);
122 return IL_FALSE;
123 }
124
125 // Uh-oh, what about 0 dimensions?!
126 if (Width < iluCurImage->Width || Height < iluCurImage->Height || Depth < iluCurImage->Depth) {
127 ilSetError(ILU_ILLEGAL_OPERATION);
128 return IL_FALSE;
129 }
130
131 if (iluCurImage->Origin == IL_ORIGIN_LOWER_LEFT) {
132 switch (iluPlacement)
133 {
134 case ILU_LOWER_LEFT:
135 AddX = 0;
136 AddY = 0;
137 break;
138 case ILU_LOWER_RIGHT:
139 AddX = Width - iluCurImage->Width;
140 AddY = 0;
141 break;
142 case ILU_UPPER_LEFT:
143 AddX = 0;
144 AddY = Height - iluCurImage->Height;
145 break;
146 case ILU_UPPER_RIGHT:
147 AddX = Width - iluCurImage->Width;
148 AddY = Height - iluCurImage->Height;
149 break;
150 case ILU_CENTER:
151 AddX = (Width - iluCurImage->Width) >> 1;
152 AddY = (Height - iluCurImage->Height) >> 1;
153 break;
154 default:
155 ilSetError(ILU_INVALID_PARAM);
156 return IL_FALSE;
157 }
158 }
159 else { // IL_ORIGIN_UPPER_LEFT
160 switch (iluPlacement)
161 {
162 case ILU_LOWER_LEFT:
163 AddX = 0;
164 AddY = Height - iluCurImage->Height;
165 break;
166 case ILU_LOWER_RIGHT:
167 AddX = Width - iluCurImage->Width;
168 AddY = Height - iluCurImage->Height;
169 break;
170 case ILU_UPPER_LEFT:

Callers

nothing calls this directly

Calls 1

ilSetErrorFunction · 0.85

Tested by

no test coverage detected