예제 #1
0
파일: NanoVG.cpp 프로젝트: ViktorNova/Carla
NanoImage::NanoImage(const Handle& handle)
    : fHandle(handle),
      fSize()
{
    DISTRHO_SAFE_ASSERT_RETURN(fHandle.context != nullptr && fHandle.imageId != 0,);

    _updateSize();
}
예제 #2
0
	void FreeImage::resize( const Math::Vec2<Size> & newSize, Filter resampleFilter ) {
		this -> resampleFilter = resampleFilter;

		if ( isLoaded() && this -> size != newSize ) {
			this -> size = newSize;
			_updateSize();
		} else
			this -> size = newSize;
	}
예제 #3
0
파일: NcursesUI.cpp 프로젝트: Julow/Nibbler
EventType		NcursesUI::getEvent(void)
{
	int				c;

	c = getch();
	if (c == 'q')
		_shouldClose = true;
	else if (c != ERR && _events.find(c) != _events.end())
		return (_events[c]);
	if (c != -1)
		std::cerr << "LOL: " << (int)c << std::endl;
	_updateSize();
	return (EVENT_NOPE);
}
예제 #4
0
파일: NcursesUI.cpp 프로젝트: Julow/Nibbler
void				NcursesUI::init(void)
{
	cbreak();
	timeout(0);
	keypad(stdscr, TRUE);
	noecho();
	curs_set(0);
	start_color();
	init_color(17, 125, 125, 125);
	init_color(18, 110, 110, 110);
	init_color(19, 95, 95, 95);
	init_color(20, 500, 30, 30);
	init_color(30, 140, 140, 140);
	init_pair(1, COLOR_WHITE, 30);
	init_pair(2, COLOR_RED, COLOR_RED);
	init_pair(3, 20, 20);
	init_pair(20, COLOR_YELLOW, COLOR_YELLOW);
	init_pair(21, COLOR_BLUE, COLOR_BLUE);
	init_pair(22, COLOR_BLACK, COLOR_BLACK);
	init_pair(23, COLOR_CYAN, COLOR_CYAN);
	init_pair(13, 17, 17);
	init_pair(14, 18, 18);
	init_pair(15, 19, 19);
	_events['1'] = EVENT_1;
	_events['2'] = EVENT_2;
	_events['3'] = EVENT_3;
	_events['4'] = EVENT_4;
	_events['5'] = EVENT_5;
	_events['6'] = EVENT_6;
	_events['7'] = EVENT_7;
	_events[265] = EVENT_1;
	_events[266] = EVENT_2;
	_events[267] = EVENT_3;
	_events[268] = EVENT_4;
	_events[269] = EVENT_5;
	_events[270] = EVENT_6;
	_events[271] = EVENT_7;
	_events['r'] = EVENT_R;
	_events[' '] = EVENT_SPACE;
	_events[KEY_UP] = EVENT_UP;
	_events[KEY_RIGHT] = EVENT_RIGHT;
	_events[KEY_DOWN] = EVENT_DOWN;
	_events[KEY_LEFT] = EVENT_LEFT;
	_updateSize();
}
예제 #5
0
	bool FreeImage::onLoad() {

		switch ( this -> loadingType ) {
			case LoadingType::EMPTY:
				{
					this -> freeImage = FreeImage_Allocate( this -> size.x, this -> size.y, this -> BPP, 0, 0, 0 );
					break;
				}
			case LoadingType::FILE: 
				{
					// Check the file signature and deduce its format.
					#ifdef WIN32
					FREE_IMAGE_FORMAT imageFormat = FreeImage_GetFileTypeU( fileNameW.toCString(), 0 );
					#else
					FREE_IMAGE_FORMAT imageFormat = FreeImage_GetFileType( fileName.toCString(), 0 );
					#endif

					// If still unknown, try to guess the file format from the file extension.  
					if ( imageFormat == FIF_UNKNOWN ) {
						#ifdef WIN32
						imageFormat = FreeImage_GetFIFFromFilenameU( fileNameW.toCString() );
						#else
						imageFormat = FreeImage_GetFIFFromFilename( fileName.toCString() );
						#endif
					}

					// If still unknown, return failure.  
					if ( imageFormat == FIF_UNKNOWN ) {
						error( String( "Free Image was unable to detect the file format : " ) << fileName );
						return false;
					}

					// Check that the plugin has reading capabilities and load the file.  
					if ( FreeImage_FIFSupportsReading( imageFormat ) ) {
						#ifdef WIN32
						this -> freeImage = FreeImage_LoadU( imageFormat, fileNameW.toCString() );
						#else
						this -> freeImage = FreeImage_Load( imageFormat, fileName.toCString() );
						#endif
					}

					if ( this -> freeImage == NULL ) {
						error( String( "Free Image was unable to load the picture : " ) << fileName );
						return false;
					}
					if ( this -> size.x == 0 || this -> size.y == 0 ) {
						this -> size.x = FreeImage_GetWidth( this -> freeImage );
						this -> size.y = FreeImage_GetHeight( this -> freeImage );
					}


					if ( this -> loadingFormat == Format::UNDEFINED ) {
						switch ( FreeImage_GetColorType( this -> freeImage ) ) {
							case FIC_PALETTE:
								_updateFormat( Format::R );
								break;
							case FIC_RGB:
								_updateFormat( Format::RGB );
								break;
							default:
								_updateFormat( Format::RGBA );
								break;
						}
					}

					log( this -> fileName << this -> size << " has been loaded successfully !" );
					break;
				}

		}


		//if we have to flip vertically.
		if ( this -> invertY )
			FreeImage_FlipVertical( this -> freeImage );
		//Change BPP
		if ( this -> BPP != FreeImage_GetBPP( this -> freeImage ) )
			_updateBPP();
		//resize
		if ( this -> size != Math::Vec2<Size>( FreeImage_GetWidth( this -> freeImage ), FreeImage_GetHeight( this -> freeImage ) ) )
			_updateSize();

		this -> stride = FreeImage_GetPitch( this -> freeImage );
		return true;
	}