예제 #1
0
파일: clr.c 프로젝트: satish2/Learn
Rgb2True*
initRgb2True ( JNIEnv* env, jclass clazz, Toolkit* Tlk )
{
  //Visual *v = DefaultVisualOfScreen( DefaultScreenOfDisplay( Tlk->dsp));
  unsigned int m;
  int      nRed, nGreen, nBlue;
  int      iRed, iGreen, iBlue;
  int      n;
  Rgb2True *map = 0;

  // !!! if ( (v->blue_mask == 0xff) && (v->green_mask == 0xff00) && (v->red_mask == 0xff0000) ){
  if (1) { // !!! DEFAULT TRUE-COLOR MODE
  	/*
	 * This is our favourite case - a direct 8-8-8 native rgb. It could be handled as
	 * a 0,0 TrueColor conversion, but (esp. for image manipulations) we can save a lot
	 * of computation by a special TrueColor mode
	 */
	DBG( AWT_CLR, printf("AWT color mode: CM_TRUE_888\n"));
	Tlk->colorMode = CM_TRUE_888;
  }
  else {
UNIMPLEMENTED((
	/*
	 * There is either a rearrangement or a non-8 bit color component involved,
	 * get start index and length of each color component. Note that the Rgb2True
	 * struct is used to compute pixelvalues from Java rgbs, i.e. the mask and shift
	 * values are relative to the Java 8-8-8 RGB.
	 */
	map = (Rgb2True*) AWT_MALLOC( sizeof( Rgb2True));

	for ( iBlue=0, m=v->blue_mask; (m & 1) == 0; iBlue++, m >>= 1);
	for ( nBlue=0; m; nBlue++, m >>= 1 );

	for ( iGreen=0, m=v->green_mask; (m & 1) == 0; iGreen++, m >>= 1);
	for ( nGreen=0; m; nGreen++, m >>= 1 );

	for ( iRed=0, m=v->red_mask; (m & 1) == 0; iRed++, m >>= 1);
	for ( nRed=0; m; nRed++, m >>= 1 );

	map->blueShift = 8 - (iBlue + nBlue);
	if ( nBlue < 8 ){  /* color reduction */
	  n = 8 - nBlue;
	  map->blueMask = (0xff >> n) << n;
	}
	else {             /* color expansion */
예제 #2
0
파일: clr.c 프로젝트: satish2/Learn
Rgb2Pseudo*
initRgb2Pseudo ( JNIEnv* env, jclass clazz, Toolkit* Tlk )
{
  Colormap dcm;
  int i, j, k;
  XColor xclr;
  Rgb2Pseudo *map;

  dcm = DefaultColormapOfScreen( DefaultScreenOfDisplay( Tlk->dsp));
  map = (Rgb2Pseudo*) AWT_MALLOC( sizeof(Rgb2Pseudo));
  xclr.flags = DoRed | DoGreen | DoBlue;

  for ( i=0; i<8; i++ ){
	for ( j=0; j<8; j++ ) {
	  for ( k=0; k<8; k++ )
		map->pix[i][j][k] = 0;
	}
  }

  initColormap( env, Tlk, dcm, map);
  Tlk->colorMode = CM_PSEUDO_256;

  return map;
}
static Image*
readGif ( GifFileType *gf )
{
  Image*          firstImg = 0;
  Image*	  img = 0;
  int             i, extCode, width, height, row, cmapSize;
  int             trans = -1, nFrames = 0, delay = 0;
  GifRecordType   rec;
  GifByteType     *ext;
  ColorMapObject  *cmap;
  GifColorType    *clrs;
  GifPixelType    *rowBuf = (GifPixelType*) AWT_MALLOC( gf->SWidth * sizeof( GifPixelType) );

  do {
	CHECK( DGifGetRecordType( gf, &rec));

	switch ( rec ) {
	case IMAGE_DESC_RECORD_TYPE:
	  CHECK( DGifGetImageDesc( gf));

	  width    = gf->Image.Width;
	  height   = gf->Image.Height;

      cmap     = (gf->Image.ColorMap) ? gf->Image.ColorMap : gf->SColorMap;
	  clrs     = cmap->Colors;
      cmapSize = cmap->ColorCount;

	  /*
	   * create our image objects and keep track of frames 
	   */
	  if ( !firstImg ) {     /* this is the first (maybe only) frame */
		firstImg = img = createImage( width, height);
	  }
	  else {                 /* this is a subsequent gif-movie frame, link it in */
		img->next = createImage( width, height);
		img = img->next;
	  }

	  /*
	   * The trans index might have been cached by a preceeding extension record. Now
	   * that we have the Image object, it's time to store it in img and to create the
	   * mask
	   */
	  if ( trans != -1 ) {
		img->trans = trans;
		createXMaskImage( X, img);
		trans = -1;
	  }

	  /*
	   * Some browsers seem to assume minimal values, and some animations
	   * seem to rely on this. But there's no safe guess, so we
	   * skip it completely
	   */
/*
	  if ( delay == 0 )
		delay = 1000;
	  else if ( delay < 100 )
		delay = 100;
*/

	  img->latency = delay;
	  img->left = gf->Image.Left;
	  img->top = gf->Image.Top;
	  img->frame = nFrames;

	  nFrames++;
	  createXImage( X, img);

	  /*
	   * start reading in the image data
	   */
	  if ( gf->Image.Interlace ) {
		/* Need to perform 4 passes on the images: */
		for ( i = 0; i < 4; i++ ) {
		  for (row = iOffset[i]; row < height; row += iJumps[i]) {
			memset( rowBuf, gf->SBackGroundColor, width);
			CHECK( DGifGetLine( gf, rowBuf, width));

			writeRow( img, rowBuf, clrs, row);
		  }
		}
	  }
	  else {
		for ( row = 0; row < height; row++) {
		  memset( rowBuf, gf->SBackGroundColor, width);
		  CHECK( DGifGetLine(gf, rowBuf, width));

		  writeRow( img, rowBuf, clrs, row);
		}
	  }
	  break;

	case EXTENSION_RECORD_TYPE:
	  CHECK( DGifGetExtension( gf, &extCode, &ext));

	  if ( extCode == 0xf9 ) {   /* graphics extension */
		/*
		 * extension record with transparency spec are preceeding description records
		 * (which create new Images), so just cache the transp index, here
		 */
		if ( ext[1] & 1 ) {      /* transparent index following */
		  trans = ext[4];
		}
		delay = ((ext[3] << 8) | ext[2]) * 10; /* delay in 1/100 secs */
	  }
	  else if ( extCode == 0xff ) {  /* application extension block */
	  }

	  while ( ext != NULL ) {
		CHECK( DGifGetExtensionNext( gf, &ext));
	  }
	  break;

	case TERMINATE_RECORD_TYPE:
	  break;

	default:                /* Should be traps by DGifGetRecordType. */
	  break;
	}
  } while ( rec != TERMINATE_RECORD_TYPE );

  if ( firstImg && (img != firstImg) ){
	img->next = firstImg;   /* link it together (as a ring) */
  }

  return firstImg;
}