MCPcopy Create free account
hub / github.com/DentonW/DevIL / iLoadPcdInternal

Function iLoadPcdInternal

DevIL/src-IL/src/il_pcd.cpp:106–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106ILboolean iLoadPcdInternal()
107{
108 ILubyte VertOrientation;
109 ILuint Width, Height, i, Total, x, CurPos = 0;
110 ILubyte *Y1=NULL, *Y2=NULL, *CbCr=NULL, r = 0, g = 0, b = 0;
111 ILuint PicNum;
112
113 if (iCurImage == NULL) {
114 ilSetError(IL_ILLEGAL_OPERATION);
115 return IL_FALSE;
116 }
117
118 iseek(72, IL_SEEK_CUR);
119 if (iread(&VertOrientation, 1, 1) != 1)
120 return IL_FALSE;
121
122 iseek(-72, IL_SEEK_CUR); // Can't rewind
123
124 PicNum = iGetInt(IL_PCD_PICNUM);
125
126 switch (PicNum)
127 {
128 case 0:
129 iseek(0x02000, IL_SEEK_CUR);
130 Width = 192;
131 Height = 128;
132 break;
133 case 1:
134 iseek(0x0b800, IL_SEEK_CUR);
135 Width = 384;
136 Height = 256;
137 break;
138 case 2:
139 iseek(0x30000, IL_SEEK_CUR);
140 Width = 768;
141 Height = 512;
142 break;
143 default:
144 ilSetError(IL_INVALID_PARAM);
145 return IL_FALSE;
146 }
147
148 if (itell() == IL_EOF) // Supposed to have data here.
149 return IL_FALSE;
150
151 Y1 = (ILubyte*)ialloc(Width);
152 Y2 = (ILubyte*)ialloc(Width);
153 CbCr = (ILubyte*)ialloc(Width);
154 if (Y1 == NULL || Y2 == NULL || CbCr == NULL) {
155 ifree(Y1);
156 ifree(Y2);
157 ifree(CbCr);
158 return IL_FALSE;
159 }
160
161 if (!ilTexImage(Width, Height, 1, 3, IL_RGB, IL_UNSIGNED_BYTE, NULL)) {
162 return IL_FALSE;
163 }

Callers 2

ilLoadPcdFFunction · 0.85
ilLoadPcdLFunction · 0.85

Calls 4

ilSetErrorFunction · 0.85
iGetIntFunction · 0.85
YCbCr2RGBFunction · 0.85
ilFixImageFunction · 0.85

Tested by

no test coverage detected