当前位置: 首页>>代码示例>>C++>>正文


C++ BScreen::ColorSpace方法代码示例

本文整理汇总了C++中BScreen::ColorSpace方法的典型用法代码示例。如果您正苦于以下问题:C++ BScreen::ColorSpace方法的具体用法?C++ BScreen::ColorSpace怎么用?C++ BScreen::ColorSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BScreen的用法示例。


在下文中一共展示了BScreen::ColorSpace方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Bounds

void
MediaView::InitObject()
{
	BScreen screen;

	fMediaFile = NULL;
	fVideoTrack = NULL;
	fAudioTrack = NULL;
	fAudioOutput = NULL;
	fMediaBar = NULL;
	fBitmap = NULL;
	fBitmapDepth = screen.ColorSpace();
	fCurTime = 0;
	fPlayerThread = B_ERROR;
	fPlaySem = B_ERROR;
	fScrubSem = B_ERROR;
	fPlaying = false;
	fSnoozing = false;
	fAudioDumpingBuffer = NULL;

	BRect mediaBarFrame = Bounds();
	mediaBarFrame.top = mediaBarFrame.bottom - kMediaBarHeight;
	fMediaBar = new _MediaBar_(mediaBarFrame, this);
	AddChild(fMediaBar);

	SetViewColor(B_TRANSPARENT_32_BIT);
}
开发者ID:HaikuArchives,项目名称:Resourcer,代码行数:27,代码来源:MediaView.cpp

示例2: Create

void BBackView::Create()
{
	BScreen * screen = new BScreen();
	color_space clrmap = screen->ColorSpace(); 
	back = new BBitmap(Bounds(), clrmap, true);
	delete screen;	
}
开发者ID:BackupTheBerlios,项目名称:wxbeos-svn,代码行数:7,代码来源:backview.cpp

示例3: Draw

void Clock::Draw(BView *view, int32)
{
	BScreen screen;
	BBitmap buffer(view->Bounds(), screen.ColorSpace(), true);
	BView offscreen(view->Bounds(), NULL, 0, 0);
	buffer.AddChild(&offscreen);
	buffer.Lock();

	int n;
	float a,R;
	float width = view->Bounds().Width();
	float height = view->Bounds().Height();
	float zoom = (height/1024) * 0.85;

	time(&tmptodaytime);
	TodayTime = localtime(&tmptodaytime);

	todaysecond = TodayTime->tm_sec;
	todayminute = TodayTime->tm_min + (todaysecond/60.0);
	todayhour   = TodayTime->tm_hour + (todayminute/60.0);

	rgb_color bg_color = {0,0,0};
	offscreen.SetHighColor(bg_color);
	offscreen.SetLowColor(bg_color);
	offscreen.FillRect(offscreen.Bounds());

	offscreen.SetHighColor(200,200,200);

	for(n=0,a=0,R=510*zoom;n<60;n++,a+=(2*M_PI)/60) {
		float x = width/2 + R * cos(a);
		float y = height/2 + R * sin(a);
		DrawBlock(&offscreen,x,y,a,14*zoom);
	}

	offscreen.SetHighColor(255,255,255);

	for(n=0,a=0,R=500*zoom;n<12;n++,a+=(2*M_PI)/12) {
		float x = width/2 + R * cos(a);
		float y = height/2 + R * sin(a);
		DrawBlock(&offscreen,x,y,a,32*zoom);
	}

	offscreen.SetHighColor(255,255,255);
	DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/60) * todayminute) - (M_PI/2), 220*zoom, 1, 8*zoom);
	DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/12) * todayhour) - (M_PI/2), 140*zoom, 1, 14*zoom);
	offscreen.FillEllipse(BPoint(width/2,height/2),24*zoom,24*zoom);
	offscreen.SetHighColor(250,20,20);
	DrawArrow(&offscreen, width/2,height/2, ( ((2*M_PI)/60) * todaysecond) - (M_PI/2), 240*zoom, 1, 4*zoom);
	offscreen.FillEllipse(BPoint(width/2,height/2),20*zoom,20*zoom);

	offscreen.Sync();
	buffer.Unlock();
	view->DrawBitmap(&buffer);
	buffer.RemoveChild(&offscreen);
}
开发者ID:jiangxilong,项目名称:haiku,代码行数:55,代码来源:SimpleClock.cpp

示例4: Objects

DeviceContext::DeviceContext
(void):
magic(DC_MAGIC),
owner(NULL),
stack(0)
{
	BScreen scr;
	color = scr.ColorSpace();
	objects = new Objects();
	memset(objects, 0, sizeof(Objects));
}
开发者ID:HaikuArchives,项目名称:ExeCoffSky,代码行数:11,代码来源:DeviceContext.cpp

示例5: frame

/*	FUNCTION:		Video :: InitPlayer
	ARGUMENTS:		format
	RETURN:			n/a
	DESCRIPTION:	Create frame buffer and init decoder
*/
void Video :: InitPlayer(media_format *format)
{
	BRect frame(0, 0,
				format->u.encoded_video.output.display.line_width - 1.0f,
				format->u.encoded_video.output.display.line_count - 1.0f);
	
	BScreen screen;
	color_space cs = screen.ColorSpace();

	//	Loop asking the track for a format we can deal with
	for (;;)
	{
		fBitmap = new BBitmap(frame, cs);
		
		media_format mf, old_mf;
		memset(&mf, 0, sizeof(media_format));
		media_raw_video_format  *rvf = &mf.u.raw_video;
		rvf->last_active = (uint32)(frame.Height() - 1.0f);
		rvf->orientation = B_VIDEO_TOP_LEFT_RIGHT;
		rvf->pixel_width_aspect = 1;
		rvf->pixel_height_aspect = 3;
		rvf->display.format = cs;
		rvf->display.line_width = (int32)frame.Width();
		rvf->display.line_count = (int32)frame.Height();
		rvf->display.bytes_per_row = fBitmap->BytesPerRow();
		
		old_mf = mf;
		fVideoTrack->DecodedFormat(&mf);
		//	check if match found
		if (old_mf.u.raw_video.display.format == mf.u.raw_video.display.format)
			break;
		
		//	otherwise, change colour space
		cs = mf.u.raw_video.display.format;
		delete fBitmap;
	}
	
	media_header mh;
	fVideoTrack->SeekToTime(0);
	int64 dummy_num_frames;
	fVideoTrack->ReadFrames((char *)fBitmap->Bits(), &dummy_num_frames, &mh);
	fVideoTrack->SeekToTime(0);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:48,代码来源:Video.cpp

示例6: bufferBitmap

void
Clock::Draw(BView *view, int32)
{
	BScreen screenView;
	BBitmap bufferBitmap(view->Bounds(), screenView.ColorSpace(), true);
	BView offscreenView(view->Bounds(), NULL, 0, 0);
	bufferBitmap.AddChild(&offscreenView);
	bufferBitmap.Lock();

	float width = view->Bounds().Width();
	float height = view->Bounds().Height();
	float zoom = (height / 1024.0) * 0.65;
	
	time_t timeInfo;
	time(&timeInfo);
	struct tm *nowTime = localtime(&timeInfo);

	float secondVal = nowTime->tm_sec;
	float minuteVal = nowTime->tm_min + (secondVal / 60.0);
	float hourVal = nowTime->tm_hour + (minuteVal / 60.0);

	offscreenView.SetHighColor(0, 0, 0);
	offscreenView.SetLowColor(0, 0, 0);
	offscreenView.FillRect(offscreenView.Bounds());

	offscreenView.SetHighColor(200, 200, 200);
	
	centerX = width / 2.0;
	centerY = height / 2.0;

	float markAngle = 0;
	float markRadius = 510.0 * zoom;

	for(int mark = 0; mark < 60; mark++, markAngle += (2 * M_PI) / 60) {
		float x = centerX + markRadius * cos(markAngle);
		float y = centerY + markRadius * sin(markAngle);
		_drawBlock(&offscreenView, x, y, markAngle, 14.0 * zoom);
	}

	offscreenView.SetHighColor(255, 255, 255);

	markAngle = 0;
	markRadius = 500.0 * zoom;
	
	for (int mark = 0; mark < 12; mark++, markAngle += (2 * M_PI) / 12) {
		float x = centerX + markRadius * cos(markAngle);
		float y = centerY + markRadius * sin(markAngle);
		_drawBlock(&offscreenView, x, y, markAngle, 32 * zoom);
	}

	offscreenView.SetHighColor(255, 255, 255);
	_drawArrow(&offscreenView, centerX, centerY,
		((2 * M_PI / 60) * minuteVal) - (M_PI / 2), 220 * zoom, 1, 8 * zoom);

	_drawArrow(&offscreenView, centerX, centerY,
		((2 * M_PI / 12) * hourVal) - (M_PI / 2), 140 * zoom, 1, 14 * zoom);
	offscreenView.FillEllipse(BPoint(centerX, centerY),
		24 * zoom, 24 * zoom);
	
	offscreenView.SetHighColor(250, 20, 20);
	_drawArrow(&offscreenView, centerX, centerY,
		((2 * M_PI / 60) * secondVal) - (M_PI / 2), 240 * zoom, 1, 4 * zoom);
	offscreenView.FillEllipse(BPoint(centerX, centerY),
		20 * zoom, 20 * zoom);

	offscreenView.Sync();
	bufferBitmap.Unlock();
	view->DrawBitmap(&bufferBitmap);
	bufferBitmap.RemoveChild(&offscreenView);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:70,代码来源:SimpleClock.cpp

示例7: buffer

void 
Message::Draw(BView *view, int32 frame)
{
	// Double-buffered drawing
	BScreen screen;
	BBitmap buffer(view->Bounds(), screen.ColorSpace(), true);
	BView offscreen(view->Bounds(), NULL, 0, 0);
	buffer.AddChild(&offscreen);
	buffer.Lock();

	// Set up the colors
	rgb_color base_color = {rand() % 25, rand() % 25, rand() % 25};
	offscreen.SetHighColor(base_color); 
	offscreen.SetLowColor(tint_color(base_color, 0.815F));
	offscreen.FillRect(offscreen.Bounds(), kCheckered);
	rgb_color colors[8] = {
		tint_color(base_color, B_LIGHTEN_1_TINT),
		tint_color(base_color, 0.795F),
		tint_color(base_color, 0.851F),
		tint_color(base_color, 0.926F),
		tint_color(base_color, 1.05F),
		tint_color(base_color, B_DARKEN_1_TINT),
		tint_color(base_color, B_DARKEN_2_TINT),
		tint_color(base_color, B_DARKEN_3_TINT),
	};

	offscreen.SetDrawingMode(B_OP_OVER);

	// Set the basic font parameters, including random font family
	BFont font;
	offscreen.GetFont(&font);
	font.SetFace(B_BOLD_FACE);
	font.SetFamilyAndStyle(*(fFontFamilies.ItemAt(rand() % fFontFamilies.CountItems())), NULL);
	offscreen.SetFont(&font);

	// Get the message
	BString *message = get_message();
	BString *origMessage = new BString();
	message->CopyInto(*origMessage, 0, message->Length());
	// Replace newlines and tabs with spaces
	message->ReplaceSet("\n\t", ' ');

	int height = (int) offscreen.Bounds().Height();
	int width = (int) offscreen.Bounds().Width();

	// From 14 to 22 iterations
	int32 iterations = (rand() % 8) + 14;
	for (int32 i = 0; i < iterations; i++) {
		// Randomly set font size and shear
		BFont font;
		offscreen.GetFont(&font);
		float fontSize = ((rand() % 320) + 42) * fScaleFactor;
		font.SetSize(fontSize);
		// Set the shear off 90 about 1/2 of the time
		if (rand() % 2 == 1)
			font.SetShear((float) ((rand() % 135) + (rand() % 45)));
		else
			font.SetShear(90.0);
		offscreen.SetFont(&font);

		// Randomly set drawing location
		int x = (rand() % width) - (rand() % width/((rand() % 8)+1));
		int y = rand() % height;

		// Draw new text
		offscreen.SetHighColor(colors[rand() % 8]);
		int strLength = message->Length();
		// See how wide this string is with the current font
		float strWidth = offscreen.StringWidth(message->String());
		int drawingLength = (int) (strLength * (width / strWidth));
		int start = 0;
		if (drawingLength >= strLength)
			drawingLength = strLength;
		else
			start = rand() % (strLength - drawingLength);
		char *toDraw = new char[drawingLength+1];
		strncpy(toDraw, message->String()+start, drawingLength);
		toDraw[drawingLength] = 0;
		offscreen.DrawString(toDraw, BPoint(x, y));
		delete toDraw;
	}

	// Now draw the full message in a nice translucent box, but only
	// if this isn't preview mode
	if (!fPreview) {
		BFont font(be_fixed_font);
		font.SetSize(14.0); 
		offscreen.SetFont(&font);
		font_height fontHeight;
		font.GetHeight(&fontHeight);
		float lineHeight = fontHeight.ascent + fontHeight.descent + fontHeight.leading;
		
		BString **lines = NULL;
		int longestLine = 0;
		int count = get_lines(origMessage, &lines, &longestLine);

		float stringWidth = font.StringWidth(lines[longestLine]->String());
		BRect box(0, 0, stringWidth + 20, (lineHeight * count) + 20);
		box.OffsetTo((width - box.Width()) / 2, height - box.Height() - 40);

//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:Message.cpp

示例8: main


//.........这里部分代码省略.........
			}
			case 't':
			{
				BuiltInTablet = true;
				break;
			}
			case 'h':
			{
				fprintf (stderr, "Recognized command line options:\n");
				fprintf (stderr, "  -v    Verbose add-on loading (useful for debugging your own)\n");
				fprintf (stderr, "  -q    Verbose quitting\n");
				fprintf (stderr, "  -x    Don't load add-ons (faster launch time)\n");
				fprintf (stderr, "  -d    Use default settings (don't load settings)\n");
				fprintf (stderr, "  -w    Force saving of settings (use with -d)\n");
				fprintf (stderr, "  -Dn   Debug verbosity level\n");
				fprintf (stderr, "  -Sn   Silence level (scripting operation)\n");
				fprintf (stderr, "  -M    Don't use MMX\n");
				fprintf (stderr, "  -c    Show recognized RGB color names at startup\n");
				fprintf (stderr, "  -C    Enable export as C struct\n");
				fprintf (stderr, "  -t    Switch on builtin Wacom tablet support\n");
				fprintf (stderr, "  -h    Display this message\n");
				break;
			}
			default:
				fprintf (stderr, "Unrecognized command line option: '%c'\n(Becasso -h displays command line usage help)\n", argv[i][1]);
			}
		}
	}
	#if defined (TIME_LIMITED)
		struct tm *mytime;
		time_t mytimet = time (NULL);
	#endif
	
#if defined (__INTEL__)
	if (UseMMX)
		UseMMX	= mmx_available();
#else
	UseMMX		= false;
#endif

	if (UseMMX)
		verbose (1, "MMX detected\n");
	else
		verbose (1, "No MMX\n");
	
	if (BuiltInTablet)
		verbose (1, "Builtin Tablet support enabled\n");
		
	mainapp = new Becasso();
	setup_alphabuffer();

	if (DebugLevel)
	{
		extern const char *Version;
		fprintf (stderr, "Becasso version %s %s, built %s\n",
			Version, (gGlobalAlpha ? "(Registered)" : "(Unregistered)"), __DATE__);
	}

	size_t bsize, ssize;
	void *becassodata, *sumdata;
	app_info info;
	mainapp->GetAppInfo (&info);
	BFile file (&info.ref, O_RDONLY);
	BResources res (&file);
	if (!(becassodata = res.FindResource ('blog', 128, &bsize)))
		fprintf (stderr, "Becasso logo resource not found\n");
	if (!(sumdata = res.FindResource ('slog', 129, &ssize)))
		fprintf (stderr, "Sum logo resource not found\n");
	BScreen screen;
	BRect becassorect = BRect (0, 0, 231, 93);
	BRect sumrect = BRect (0, 0, 63, 83);
	BBitmap *becasso = new BBitmap (becassorect, (screen.ColorSpace() == B_COLOR_8_BIT) ? B_COLOR_8_BIT : B_RGB32);
	// This strange color space thing is because we can't store bitmaps in 16 bit depth, so we use
	// a 32bit version for this screen mode (which doesn't look too bad).
	BBitmap *sum = new BBitmap (sumrect, B_RGB32);
	becasso->SetBits (becassodata, bsize, 0, B_RGB32);
	sum->SetBits (sumdata, ssize, 0, B_RGB32);
	BRect center = BRect (0, 0, 280, 210);
	center.OffsetTo (screen.Frame().Width()/2 - 140, screen.Frame().Height()/2 - 105);
	splash = new SplashWindow (center, becasso, sum);
	splash->Minimize (SilentOperation >= 3);
	splash->Show();
	mainapp->LoadAddOns();
	#if defined (TIME_LIMITED)
		mytime = localtime (&mytimet);
//		if (mytime->tm_year == 97 && mytime->tm_mon < 11)
		if (mytime->tm_year == 97)
			mainapp->Run();
		else
		{
			BAlert *alert = new BAlert ("", "This demo version of Becasso has expired.\nOn http://www.sumware.demon.nl you can find info on obtaining a newer version.\nThanks for your interest in Becasso!", "OK", NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
			alert->Go();
		}
	#else
		mainapp->Run();
	#endif
	delete mainapp;
//	delete BTranslatorRoster::Default();
	return 0;
}
开发者ID:gedrin,项目名称:Becasso,代码行数:101,代码来源:BecassoMain.cpp


注:本文中的BScreen::ColorSpace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。