Exemple #1
0
// Internal function used to get the Pix header from the current file.
ILboolean iGetPixHead(PIXHEAD *Header)
{
	if (iread(Header, sizeof(PIXHEAD), 1) != 1)
		return IL_FALSE;

	BigUShort(&Header->Width);
	BigUShort(&Header->Height);
	BigUShort(&Header->OffX);
	BigUShort(&Header->OffY);
	BigUShort(&Header->Bpp);

	return IL_TRUE;
}
Exemple #2
0
// Internal function used to get the Psd header from the current file.
static ILboolean iGetPsdHead(SIO *io, PSDHEAD *Header)
{
  if (SIOread(io, Header, sizeof(*Header), 1) != 1)
    return IL_FALSE;

  BigUShort(&Header->Version);
  BigUShort(&Header->Channels);

  BigUInt  (&Header->Height);
  BigUInt  (&Header->Width);
  BigUShort(&Header->Depth);
  BigUShort(&Header->Mode);

  return IL_TRUE;
}
Exemple #3
0
// Internal function used to get the .sgi header from the current file.
ILboolean iGetSgiHead(iSgiHeader *Header)
{
	if (iread(Header, sizeof(iSgiHeader), 1) != 1)
		return IL_FALSE;

	BigUShort(&Header->MagicNum);
	BigUShort(&Header->Dim);
	BigUShort(&Header->XSize);
	BigUShort(&Header->YSize);
	BigUShort(&Header->ZSize);
	BigInt(&Header->PixMin);
	BigInt(&Header->PixMax);
	BigInt(&Header->Dummy1);
	BigInt(&Header->ColMap);

	return IL_TRUE;
}
Exemple #4
0
ILuint GetShort(DICOMHEAD *Header, ILushort GroupNum)
{
	ILushort Num;

	iread(&Num, 1, 2);
	// The 0x02 group is always little endian.
	if (GroupNum == 0x02) {
		UShort(&Num);
		return Num;
	}
	// Now we have to swizzle it if it is not 0x02.
	if (Header->BigEndian)
		BigUShort(&Num);
	else
		UShort(&Num);

	return Num;
}
Exemple #5
0
ILboolean ParseResources(ILimage* image, ILuint ResourceSize, ILubyte *Resources)
{
	ILushort	ID;
	ILubyte		NameLen;
	ILuint		Size;

	if (Resources == NULL) {
		il2SetError(IL_INTERNAL_ERROR);
		return IL_FALSE;
	}

	while (ResourceSize > 13) {  // Absolutely has to be larger than this.
		if (strncmp("8BIM", (const char*)Resources, 4)) {
			//return IL_FALSE;
			return IL_TRUE;  // 05-30-2002: May not necessarily mean corrupt data...
		}
		Resources += 4;

		ID = *((ILushort*)Resources);
		BigUShort(&ID);
		Resources += 2;

		NameLen = *Resources++;
		// NameLen + the byte it occupies must be padded to an even number, so NameLen must be odd.
		NameLen = NameLen + (NameLen & 1 ? 0 : 1);
		Resources += NameLen;

		// Get the resource data size.
		Size = *((ILuint*)Resources);
		BigUInt(&Size);
		Resources += 4;

		ResourceSize -= (4 + 2 + 1 + NameLen + 4);

		switch (ID)
		{
			case 0x040F:  // ICC Profile
				if (Size > ResourceSize) {  // Check to make sure we are not going past the end of Resources.
					il2SetError(IL_ILLEGAL_FILE_VALUE);
					return IL_FALSE;
				}
				image->Profile = (ILubyte*)ialloc(Size);
				if (image->Profile == NULL) {
					return IL_FALSE;
				}
				memcpy(image->Profile, Resources, Size);
				image->ProfileSize = Size;
				break;

			default:
				break;
		}

		if (Size & 1)  // Must be an even number.
			Size++;
		ResourceSize -= Size;
		Resources += Size;
	}

	return IL_TRUE;
}