| 17 | |
| 18 | |
| 19 | ILAPI ILboolean ILAPIENTRY ilInitImage(ILimage *Image, ILuint Width, ILuint Height, ILuint Depth, ILubyte Bpp, ILenum Format, ILenum Type, void *Data) |
| 20 | { |
| 21 | ILubyte BpcType = ilGetBpcType(Type); |
| 22 | if (BpcType == 0) { |
| 23 | ilSetError(IL_INVALID_PARAM); |
| 24 | return IL_FALSE; |
| 25 | } |
| 26 | |
| 27 | memset(Image, 0, sizeof(ILimage)); |
| 28 | |
| 29 | //// |
| 30 | if (Width == 0) Width = 1; |
| 31 | if (Height == 0) Height = 1; |
| 32 | if (Depth == 0) Depth = 1; |
| 33 | Image->Width = Width; |
| 34 | Image->Height = Height; |
| 35 | Image->Depth = Depth; |
| 36 | Image->Bpp = Bpp; |
| 37 | Image->Bpc = BpcType; |
| 38 | Image->Bps = Width * Bpp * Image->Bpc; |
| 39 | Image->SizeOfPlane = Image->Bps * Height; |
| 40 | Image->SizeOfData = Image->SizeOfPlane * Depth; |
| 41 | Image->Format = Format; |
| 42 | Image->Type = Type; |
| 43 | Image->Origin = IL_ORIGIN_LOWER_LEFT; |
| 44 | Image->Pal.PalType = IL_PAL_NONE; |
| 45 | Image->DxtcFormat = IL_DXT_NO_COMP; |
| 46 | Image->DxtcData = NULL; |
| 47 | |
| 48 | Image->Data = (ILubyte*)ialloc(Image->SizeOfData); |
| 49 | if (Image->Data == NULL) { |
| 50 | return IL_FALSE; |
| 51 | } |
| 52 | |
| 53 | if (Data != NULL) { |
| 54 | memcpy(Image->Data, Data, Image->SizeOfData); |
| 55 | } |
| 56 | |
| 57 | return IL_TRUE; |
| 58 | } |
| 59 | |
| 60 | |
| 61 |
no test coverage detected