Esempio n. 1
0
bool
GIFLoad::ReadGIFHeader()
{
	// standard header
	unsigned char header[13];
	if (fInput->Read(header, 13) < 13)
		return false;

	fWidth = header[6] + (header[7] << 8);
	fHeight = header[8] + (header[9] << 8);

	fPalette = new(std::nothrow) LoadPalette();
	if (fPalette == NULL)
		return false;

	// Global palette
	if (header[10] & GIF_LOCALCOLORMAP) {
		fPalette->size_in_bits = (header[10] & 0x07) + 1;
		if (debug) {
			syslog(LOG_INFO, "GIFLoad::ReadGIFHeader() - "
				"Found %d bit global palette\n",
				fPalette->size_in_bits);
		}
		int s = 1 << fPalette->size_in_bits;
		fPalette->size = s;

		unsigned char gp[256 * 3];
		if (fInput->Read(gp, s * 3) < s * 3)
			return false;

		for (int x = 0; x < s; x++)
			fPalette->SetColor(x, gp[x * 3], gp[x * 3 + 1], gp[x * 3 + 2]);

		fPalette->backgroundindex = header[11];
	} else {
		// install BeOS system palette in case local palette isn't present
		color_map* map = (color_map*)system_colors();
		for (int x = 0; x < 256; x++) {
			fPalette->SetColor(x, map->color_list[x].red,
				map->color_list[x].green, map->color_list[x].blue);
		}
		fPalette->size = 256;
		fPalette->size_in_bits = 8;
	}

	return true;
}
Esempio n. 2
0
ColorMenu::ColorMenu (const char *name, BView *_view, int h, int v, float s)
: BMenu (name, h*s, v*s)
{
	index = 0;
	for (int i = 0; i < v; i++)
		for (int j = 0; j < h; j++)
		{
			BRect cframe = BRect (j*s, i*s, (j + 1)*s, (i + 1)*s);
			AddItem (new ColorItem (system_colors()->color_list[index]), cframe);
		}
	Mark (0);
	view = _view;
	hs = h*s;
	vs = v*s;
	parent = NULL;
	fWindow = NULL;
}
Esempio n. 3
0
void
DockItem::MakeHighlitIcon( void )
{
	size_t size;
	BBitmap *icon, *iconHi;
	BScreen screen;

	for ( int i=0; i<2; i++ ) {

		switch ( i ) {
		case 0:
			size = 1024;
			icon = mLargeIcon;
			iconHi = mLargeIconHi;
			break;
		case 1:
			size = 256;
			icon = mSmallIcon;
			iconHi = mSmallIconHi;
			break;
		}
		
		uchar *hilitBits = new uchar[size];
		uchar *hilitBitsPtr = &hilitBits[0];
		uchar *bitsPtr = (uchar *)icon->Bits();
		rgb_color hilitColor;
		for ( int i=0; i<size; i++ ) {
			if ( *bitsPtr != B_TRANSPARENT_8_BIT ) {
				hilitColor = system_colors()->color_list[*bitsPtr++];
				hilitColor.red *= 0.7;
				hilitColor.green *= 0.7;
				hilitColor.blue *= 0.7;
				*hilitBitsPtr++ = screen.IndexForColor( hilitColor );
			} else {
				*hilitBitsPtr++ = *bitsPtr++;
			}
		}
		iconHi->SetBits( hilitBits, size, 0, B_COLOR_8_BIT );

	}
}