Example #1
0
static int de_identify_gemraster(deark *c)
{
	i64 ver, x2;
	i64 nplanes;

	if(!de_input_file_has_ext(c, "img") &&
		!de_input_file_has_ext(c, "ximg"))
	{
		return 0;
	}
	ver = de_getu16be(0);
	if(ver!=1 && ver!=2 && ver!=3) return 0;
	x2 = de_getu16be(2);
	if(x2<0x0008 || x2>0x0800) return 0;
	nplanes = de_getu16be(4);
	if(!(nplanes>=1 && nplanes<=8) && nplanes!=15 && nplanes!=16 && nplanes!=24 &&
		nplanes!=32)
	{
		return 0;
	}
	if(ver==1 && x2==0x08) return 70;
	if(!dbuf_memcmp(c->infile, 16, "XIMG", 4)) {
		return 100;
	}
	return 10;
}
Example #2
0
File: tga.c Project: jsummers/deark
static int de_identify_tga(deark *c)
{
	u8 b[18];
	u8 x;
	int has_tga_ext;

	if(has_signature(c)) {
		return 100;
	}

	// TGA v1 format has no signature, but there are only a few common types of
	// it. We'll at least try to identify anything that we support.
	de_read(b, 0, 18);

	if(b[1]>1) return 0; // Color map type should be 0 or 1.

	// bits/pixel:
	if(b[16]!=1 && b[16]!=8 && b[16]!=15 && b[16]!=16 && b[16]!=24 && b[16]!=32) return 0;

	if(b[2]!=0 && b[2]!=1 && b[2]!=2 && b[2]!=3 &&
		b[2]!=9 && b[2]!=10 && b[2]!=11 && b[2]!=32 && b[2]!=33)
	{
		return 0; // Unknown image type
	}

	if(b[12]==0 && b[13]==0) return 0; // Width can't be 0.
	if(b[14]==0 && b[15]==0) return 0; // Height can't be 0.

	// Bits per palette entry. Supposed to be 0 if there is no palette, but
	// in practice it may be 24 instead.
	if((b[1]==0 && b[7]==0) || b[7]==15 || b[7]==16 || b[7]==24 || b[7]==32) {
		;
	}
	else {
		return 0;
	}

	has_tga_ext = de_input_file_has_ext(c, "tga");

	x = b[17]&0x0f; // Number of attribute bits
	if(x!=0 && x!=1 && x!=8 && !has_tga_ext) return 0;

	if(has_tga_ext) {
		return 100;
	}
	if(de_input_file_has_ext(c, "vst")) {
		return 40;
	}
	return 8;
}
Example #3
0
static int de_identify_macpaint(deark *c)
{
	de_byte buf[8];

	de_read(buf, 65, 8);

	// Not all MacPaint files can be easily identified, but this will work
	// for some of them.
	if(!de_memcmp(buf, "PNTGMPNT", 8)) return 80;
	if(!de_memcmp(buf, "PNTG", 4)) return 70;

	if(de_input_file_has_ext(c, "mac")) return 10;
	if(de_input_file_has_ext(c, "macp")) return 15;
	if(de_input_file_has_ext(c, "pntg")) return 15;
	return 0;
}
Example #4
0
static int de_identify_alphabmp(deark *c)
{
	i64 flg;

	if(!de_input_file_has_ext(c, "bmp")) return 0;

	flg = de_getu16le(0);
	if(flg==0xffff || flg==0xfffe) {
		return 60;
	}
	return 0;
}
Example #5
0
static int de_identify_fnt(deark *c)
{
	de_int64 ver;

	// TODO: Better format detection.
	if(de_input_file_has_ext(c, "fnt")) {
		ver = de_getui16le(0);
		if(ver==0x0100 || ver==0x0200 || ver==0x0300)
			return 10;
	}
	return 0;
}
Example #6
0
static int de_identify_iptc(deark *c)
{
	de_byte b;

	// First byte of each dataset is 0x1c.
	if(de_getbyte(0)!=0x1c) return 0;

	// Check the record number. Record numbers 1-9 are known.
	b = de_getbyte(1);
	if(b<1 || b>15) return 0;

	// This is not meant to imply that .iptc is an official file extension for
	// IPTC data. It's just that it's used by Deark when extracting IPTC data
	// to a file.
	if(!de_input_file_has_ext(c, "iptc")) return 0;

	return 60;
}