Example #1
0
boolean _cameraSetBin_RGB(CAMERA* camera, uint8_t binNo, const COLOR* min, const COLOR* max){
	boolean rtn = FALSE;

	if(binNo < _cameraNumColorBins(camera)){
		CAMERA_BIN* bin = &camera->bins[binNo];

		COLOR _min;
		COLOR _max;
		COLOR_RGB *_minRGB;
		COLOR_RGB *_maxRGB;

		// Convert min to rgb
		_minRGB = color2rgb(min, &_min);

		// Convert max to rgb
		_maxRGB = color2rgb(max, &_max);

		if(_minRGB->r > _maxRGB->r){
			// swap the red values
			uint8_t c = _minRGB->r;
			_minRGB->r = _maxRGB->r;
			_maxRGB->r = c;
		}

		if(_minRGB->g > _maxRGB->g){
			// swap the green values
			uint8_t c = _minRGB->g;
			_minRGB->g = _maxRGB->g;
			_maxRGB->g = c;
		}

		if(_minRGB->b > _maxRGB->b){
			// swap the blue values
			uint8_t c = _minRGB->b;
			_minRGB->b = _maxRGB->b;
			_maxRGB->b = c;
		}

		if(colorEquals(&_min, &bin->min)==FALSE || colorEquals(&_max, &bin->max)==FALSE){
			// The colours have changed

			// Put into color bank table
			color2rgb(&_min, &bin->min);
			color2rgb(&_max, &bin->max);
			bin->dirty = TRUE;
		}

		rtn = bin->active = TRUE;

	}
	return rtn;
}
Example #2
0
void trans_graph()
{
   // remember if  we are in batch mode
   Bool_t batch = gROOT->IsBatch();

   // switch to batch mode
   gROOT->SetBatch(kTRUE);

   // execute graph.C macro
   gROOT->Macro("$ROOTSYS/tutorials/graphs/graph.C");

   // create gVirtualPS object
   TImageDump dmp("dummy.png");
   TImage *fore = dmp.GetImage();  // image associated with image_dump

   // resize canvas
   gPad->SetCanvasSize(400, 300);
   gPad->Paint(); // paint gPad on fore image associated with TImageDump

   // open background image
   TImage *back = TImage::Open("$ROOTSYS/tutorials/image/rose512.jpg");

   // choose colors to be transparent
   TColor *bk1 = gROOT->GetColor(gPad->GetFillColor());
   TColor *bk2 = gROOT->GetColor(gPad->GetFrame()->GetFillColor());
   UInt_t rgb1 = color2rgb(bk1);
   UInt_t rgb2 = color2rgb(bk2);

   // get directly accessible ARGB array
   UInt_t *argb = fore->GetArgbArray();
   UInt_t w = fore->GetWidth();
   UInt_t h = fore->GetHeight();

   // scan all pixels in fore image and
   // make rgb1, rgb2 colors transparent.
   for (UInt_t i = 0; i < h; i++) {
      for (UInt_t j = 0; j < w; j++) {
         Int_t idx = i*w + j;

         // RGB part of ARGB color
         UInt_t col = argb[idx] & 0xffffff;

         // 24..31 bits define transparency of the color in the range 0 - 0xff
         // for example, 0x00000000 - black color with 100% transparency
         //              0xff000000 - non-transparent black color

         if ((col == rgb1) || (col == rgb2)) { //
            argb[idx] = 0; // 100% transparent
         } else {
            argb[idx] = 0xff000000 + col;  // make other pixels non-transparent
         }
      }
   }

   // alphablend back and fore images
   back->Merge(fore, "alphablend", 20, 20);

   // write result image in PNG format
   back->WriteImage("trans_graph.png");
   printf("*************** File trans_graph.png created ***************\n");

   delete back;

   // switch back to GUI mode
   if (!batch) gROOT->SetBatch(kFALSE);
}
Example #3
0
rgb HexItem::get_color()
{
    return color2rgb(color);
    //return 0x703d0b;
}
Example #4
0
rgb HexItem::get_border()
{
    return color2rgb(border);
}
Example #5
0
int initBG()
{
	t_bgctx *ctx = &bgctx;
	int backup_size,bg_flag,bg_buf_width;
	void (*color2rgb)(u32 color, u8 *r, u8 *g, u8*b);
	u32 (*rgb2color)(u32 r, u32 g, u32 b);
	switch(ctx->pixelformat)
	{
	case PSP_DISPLAY_PIXEL_FORMAT_565:
		color2rgb = color2rgb565;
		rgb2color = rgb2color565;
		bg_flag = 2;
		break;
	case PSP_DISPLAY_PIXEL_FORMAT_5551:
		color2rgb = color2rgb5551;
		rgb2color = rgb2color5551;
		bg_flag = 2;
		break;
	case PSP_DISPLAY_PIXEL_FORMAT_4444:
		color2rgb = color2rgb4444;
		rgb2color = rgb2color4444;
		bg_flag = 2;
		break;
	case PSP_DISPLAY_PIXEL_FORMAT_8888:
		color2rgb = color2rgb8888;
		rgb2color = rgb2color8888;
		bg_flag = 4;
		break;
	}
	
	if(config.blendmore){
		BACKUP_X1=4;
		BACKUP_X2=468;
	}
	else{
		BACKUP_X1=96;
		BACKUP_X2=384;	
	}
	backup_size = (BACKUP_X2-BACKUP_X1)*(BACKUP_Y2-BACKUP_Y1) * bg_flag ;
	bg_buf_width = (BACKUP_X2-BACKUP_X1)*bg_flag;
	
	bg_buf = smalloc(backup_size, 0xF000);
	if(bg_buf==NULL) return 1;
	
	int i;
	for(i=BACKUP_Y1;i<BACKUP_Y2;i++){
		mips_memcpy(bg_buf+(i-BACKUP_Y1)*bg_buf_width,
		(void *)((unsigned int)ctx->vram+(i*ctx->bufferwidth+BACKUP_X1)*bg_flag),
		bg_buf_width);
	}
	
	u8 r, g, b;
	u16 * vram16 = (u16 *)bg_buf;
	u32 * vram32 = (u32 *)bg_buf;
	int x,y;
	for(y=0;y<(BACKUP_Y2-BACKUP_Y1);y++){
		int tmp = y * (BACKUP_X2-BACKUP_X1);
		for(x=tmp;x<tmp + (BACKUP_X2-BACKUP_X1);x++){
			switch (ctx->pixelformat)
			{
				case PSP_DISPLAY_PIXEL_FORMAT_565:
				case PSP_DISPLAY_PIXEL_FORMAT_5551:
				case PSP_DISPLAY_PIXEL_FORMAT_4444:
					color2rgb(vram16[x],&r,&g,&b);
					break;
				case PSP_DISPLAY_PIXEL_FORMAT_8888:		 			
					color2rgb(vram32[x],&r,&g,&b);
					break;
			}
			r = (ctx->bg_a * ctx->bg_r) / 256 + (255-ctx->bg_a) * r / 256;
			g = (ctx->bg_a * ctx->bg_g) / 256 + (255-ctx->bg_a) * g / 256;
			b = (ctx->bg_a * ctx->bg_b) / 256 + (255-ctx->bg_a) * b / 256;
			switch (ctx->pixelformat)
			{
				case PSP_DISPLAY_PIXEL_FORMAT_565:
				case PSP_DISPLAY_PIXEL_FORMAT_5551:
				case PSP_DISPLAY_PIXEL_FORMAT_4444:
					vram16[x] = rgb2color(r,g,b);
					break;
				case PSP_DISPLAY_PIXEL_FORMAT_8888:
					vram32[x] = rgb2color(r,g,b);
					break;
			}
		}
	}
	
	return 0;
}