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


C++ SDL_DisplayFormatAlpha函数代码示例

本文整理汇总了C++中SDL_DisplayFormatAlpha函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_DisplayFormatAlpha函数的具体用法?C++ SDL_DisplayFormatAlpha怎么用?C++ SDL_DisplayFormatAlpha使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: IMG_Load

/**
 * Icon set shared by all menus
 */
void MenuManager::loadIcons() {

	icons = IMG_Load(mods->locate("images/icons/icons_small.png").c_str());
	if(!icons) {
		fprintf(stderr, "Couldn't load icons: %s\n", IMG_GetError());
		SDL_Quit();
		std::exit(1);
	}

	// optimize
	SDL_Surface *cleanup = icons;
	icons = SDL_DisplayFormatAlpha(icons);
	SDL_FreeSurface(cleanup);
}
开发者ID:perplexingcabinet,项目名称:flare-engine,代码行数:17,代码来源:MenuManager.cpp

示例2: SDL_FreeSurface

void GameStateLoad::loadPortrait(int slot) {
	SDL_FreeSurface(portrait);
	portrait = NULL;
	
	if (stats[slot].name == "") return;
	
	portrait = IMG_Load((PATH_DATA + "images/portraits/" + stats[slot].portrait + ".png").c_str());
	if (!portrait) return;
	
	// optimize
	SDL_Surface *cleanup = portrait;
	portrait = SDL_DisplayFormatAlpha(portrait);
	SDL_FreeSurface(cleanup);
}
开发者ID:amprice,项目名称:flare,代码行数:14,代码来源:GameStateLoad.cpp

示例3: IMG_Load

void Splash::loadTexture(void)
{
    SDL_Surface *image = IMG_Load("data/foka logo.png");
    SDL_DisplayFormatAlpha(image);
    SDL_Rect imageRect;

    imageRect.x = 0;
    imageRect.y = 0;
    imageRect.w = 700;
    imageRect.h = 700;
    this->texture = this->loadModel(image, imageRect);

    SDL_FreeSurface(image);
}
开发者ID:zivlakmilos,项目名称:Parmecium,代码行数:14,代码来源:splash.cpp

示例4: IMG_Load

Image Graphic::newImage(const char* filename) {
	Image image;

	SDL_Surface* surface_temp = NULL;
	surface_temp = IMG_Load(filename);

	image.onInit(SDL_DisplayFormatAlpha(surface_temp));

	if (surface_temp)
		SDL_FreeSurface(surface);
	surface_temp = NULL;

	return image;
}
开发者ID:joaotargino,项目名称:moolajoo-tcg,代码行数:14,代码来源:Graphic.cpp

示例5: Crop

// crop one surface to a new one, with tiling when needed
extern SDL_Surface* Crop(SDL_Surface *base, long int ox, long int oy, long int nw, long int nh)
{
	SDL_Surface *tform = NULL;
	SDL_Surface *ttmp = SDL_CreateRGBSurface(SDL_SWSURFACE,nw,nh,base->format->BitsPerPixel,base->format->Rmask,base->format->Gmask,base->format->Bmask,base->format->Amask);
	tform = SDL_DisplayFormatAlpha(ttmp);
	SDL_FreeSurface(ttmp);
	while ( ox < 0 )
		ox += base->w;
	while ( oy < 0 )
		oy += base->h;
	while ( ox >= base->w )
		ox -= base->w;
	while ( oy >= base->h )
		oy -= base->h;
	if ( nw <= 0 || nh <= 0 )
		return tform;
	long int px, py, nx, ny;
	uint32_t pux, pnx;
	uint8_t R,G,B,A;
	px = ox;
	py = oy;
	nx = 0;
	ny = 0;
	SDL_LockSurface(base);
	SDL_LockSurface(tform);
	do
	{
		pux = getpixel(base,px,py);
		SDL_GetRGBA(pux,base->format,&R,&G,&B,&A);
		pnx = SDL_MapRGBA(tform->format,R,G,B,A);
		putpixel(tform,nx,ny,pnx);
		nx++;
		px++;
		if ( px >= base->w )
			px = ox;
		if ( nx >= nw )
		{
			nx = 0;
			px = ox;
			ny++;
			py++;
			if ( py >= base->h )
				py = oy;
		}
	}
	while ( (nx < nw) && (ny < nh) );
	SDL_UnlockSurface(tform);
	SDL_UnlockSurface(base);
	return tform;
}
开发者ID:OrdinaryMagician,项目名称:nasu,代码行数:51,代码来源:helpers_drawextras.c

示例6: initInterface

// Loads initial interface data
void initInterface()
{
	FILE *hud;			// config file
	Sprite *temp;
	SDL_Surface *menu;

	// Open the config file, load defaults if it fails
	hud = fopen("config/hud.txt","r");
	if(hud == NULL)
	{
		fprintf(stderr,"HUD.txt failed to open, using defaults\n");
		loadDefHUD();
	}

	else
	{
		loadHUD(hud);
	}

	// Load menu sprite
	temp = LoadSprite("hud/menu.png",640,480);
	menu = IMG_Load("hud/menu.png");
	SDL_SetColorKey(menu, 0, 0);
	temp->image = SDL_DisplayFormatAlpha(menu);
	SDL_FreeSurface(menu);

	// set HUD transparency slider info
	aSlider.x = ORIGIN_X + 65;
	aSlider.y = ORIGIN_Y - 180;
	aSlider.w = 50;
	aSlider.h = 24;
	aSlide = false;

	// set scroll speed slider info
	sSlider.x = ORIGIN_X + 65;
	sSlider.y = ORIGIN_Y - 180;
	sSlider.w = 50;
	sSlider.h = 24;
	HUD.sSlide = false;
	
	// start invisible
	alpha = SDL_ALPHA_TRANSPARENT;
	
	// Load button info
	initButtons();

	HUD.grabPanel = 0;
	HUD.menu = 1;
	HUD.ttips = true;
}
开发者ID:vscuorzo,项目名称:mandest,代码行数:51,代码来源:hud.c

示例7: SDL_DisplayFormatAlpha

// simple static function that will load a surface for us
SDL_Surface* CSurface::OnLoad(char* File) {
    SDL_Surface* Surf_Temp = NULL;
    SDL_Surface* Surf_Return = NULL;
 
    if((Surf_Temp = IMG_Load(File)) == NULL) {
        return NULL;
    }
 
	// here we're optimizing the image - using "SDL_DisplayFormatAlpha" instead of "SDL_DisplayFormat" because the former allows us to designate a color channel, in our case bright pink, as transparent. This helps a lot when rendering our sprites
    Surf_Return = SDL_DisplayFormatAlpha(Surf_Temp);
    SDL_FreeSurface(Surf_Temp);
 
    return Surf_Return;
}
开发者ID:mrundle,项目名称:SpaceFighter,代码行数:15,代码来源:CSurface.cpp

示例8: newsurface

/* Create a new surface containing a single tile with transparent
 * pixels, as indicated by the mask tile.
 */
static SDL_Surface *extractmaskedtile(SDL_Surface *src,
				      int ximg, int yimg, int wimg, int himg,
				      int xmask, int ymask)
{
    SDL_Surface	       *dest;
    SDL_Surface	       *temp;
    SDL_Rect		rect;
    unsigned char      *s, *d;
    Uint32		transp, black;
    int			x, y;

    rect.x = ximg;
    rect.y = yimg;
    rect.w = wimg;
    rect.h = himg;
    dest = newsurface(rect.w, rect.h, TRUE);
    SDL_BlitSurface(src, &rect, dest, NULL);

    black = SDL_MapRGB(src->format, 0, 0, 0);
    transp = SDL_MapRGBA(dest->format, 0, 0, 0, SDL_ALPHA_TRANSPARENT);

    if (SDL_MUSTLOCK(src))
	SDL_LockSurface(src);
    if (SDL_MUSTLOCK(dest))
	SDL_LockSurface(dest);
    d = (Uint8*)dest->pixels;
    s = (Uint8*)src->pixels + ymask * src->pitch
			    + xmask * src->format->BytesPerPixel;
    for (y = 0 ; y < dest->h ; ++y) {
	for (x = 0 ; x < dest->w ; ++x) {
	    if (pixelat(src, xmask + x, ymask + y) == black)
		((Uint32*)d)[x] = transp;
	}
	s += src->pitch;
	d += dest->pitch;
    }
    if (SDL_MUSTLOCK(src))
	SDL_UnlockSurface(src);
    if (SDL_MUSTLOCK(dest))
	SDL_UnlockSurface(dest);

    temp = dest;
    dest = SDL_DisplayFormatAlpha(temp);
    SDL_FreeSurface(temp);
    if (!dest)
	die("%s", SDL_GetError());
    SDL_SetAlpha(dest, SDL_SRCALPHA | SDL_RLEACCEL, 0);
    return dest;
}
开发者ID:BR903,项目名称:tworld,代码行数:52,代码来源:sdltile.c

示例9: TTF_RenderText_Blended

Image Graphic::newImageFromText(const char* text) {
	Image image;

	SDL_Surface* surface_temp = NULL;

	surface_temp = TTF_RenderText_Blended(System::getInstance()->getFont(), text, System::getInstance()->getColor());

	image.onInit(SDL_DisplayFormatAlpha(surface_temp));

	if (surface_temp)
		SDL_FreeSurface(surface);
	surface_temp = NULL;

	return image;
}
开发者ID:joaotargino,项目名称:moolajoo-tcg,代码行数:15,代码来源:Graphic.cpp

示例10: loadedImage

boost::shared_ptr<SDL_Surface> CGViewer::loadImage(const std::string& filename)
{
    boost::shared_ptr<SDL_Surface> loadedImage(
            IMG_Load(filename.c_str()),
            boost::bind(&SafeFreeSurface, _1));
    if (!loadedImage.get())
        throw std::runtime_error(IMG_GetError());

	//dostosowanie grafiki do wyswietlenia z kanalem przezroczystosci
    boost::shared_ptr<SDL_Surface> optimizedImage( 
			SDL_DisplayFormatAlpha(loadedImage.get()), 
			boost::bind(&SafeFreeSurface, _1) ); 

    return optimizedImage;
}
开发者ID:cezarygerard,项目名称:arpservice,代码行数:15,代码来源:CGViewer.cpp

示例11: IMG_Load

SDL_Surface* Render::assignImage(const char* file){
	if (file == NULL)
		return NULL;
	
	SDL_Surface* newImage;
	SDL_Surface* tempImage = IMG_Load(file);

	if (tempImage == NULL) 
		return NULL;

	newImage = SDL_DisplayFormatAlpha(tempImage);
	SDL_FreeSurface(tempImage);

	return newImage;
}
开发者ID:joao29a,项目名称:checkersGame,代码行数:15,代码来源:Render.cpp

示例12: IMG_Load

SDL_Surface *load_image(const char* filename,Uint8 r, Uint8 g, Uint8 b)
{
    SDL_Surface* loadedImage=NULL;
    SDL_Surface* optimizedImage=NULL;
    loadedImage = IMG_Load(filename);
    if(loadedImage!=NULL)
    {
        optimizedImage=SDL_DisplayFormatAlpha(loadedImage);
        Uint32 colorkey=SDL_MapRGB(loadedImage->format,r,g,b);

        SDL_SetColorKey(optimizedImage,SDL_SRCCOLORKEY,colorkey);
        SDL_FreeSurface(loadedImage);
    }
    return optimizedImage;
}
开发者ID:cscheid,项目名称:algebraic-numbers,代码行数:15,代码来源:Utils.cpp

示例13: IMG_Load

int Img::loadImage(char* sFile)
{
	SDL_Surface* loadedImage = NULL;

	loadedImage = IMG_Load(sFile);
	if(loadedImage != NULL)
	{
		_pImg = SDL_DisplayFormatAlpha(loadedImage);
		SDL_FreeSurface(loadedImage);
	}
	else
		return -1;

	return 0;
}
开发者ID:arajar,项目名称:Aeon-War,代码行数:15,代码来源:Img.cpp

示例14: IMG_Load

void MenuCharacter::loadGraphics() {

	background = IMG_Load("images/menus/character.png");
	proficiency = IMG_Load("images/menus/character_proficiency.png");
	upgrade = IMG_Load("images/menus/upgrade.png");
	if(!background || !proficiency || !upgrade) {
		fprintf(stderr, "Couldn't load image: %s\n", IMG_GetError());
		SDL_Quit();
	}
	
	// optimize
	SDL_Surface *cleanup = background;
	background = SDL_DisplayFormatAlpha(background);
	SDL_FreeSurface(cleanup);
	
	cleanup = proficiency;
	proficiency = SDL_DisplayFormatAlpha(proficiency);
	SDL_FreeSurface(cleanup);

	cleanup = upgrade;
	upgrade = SDL_DisplayFormatAlpha(upgrade);
	SDL_FreeSurface(cleanup);
		
}
开发者ID:Longer,项目名称:flare,代码行数:24,代码来源:MenuCharacter.cpp

示例15:

struct SDL_Surface *load_image(const char *file_name)
{
	SDL_Surface *surface;
	if ((surface = IMG_Load(file_name)) == NULL)
		return NULL;

	SDL_Surface *optimized_surface;
	if ((optimized_surface = SDL_DisplayFormatAlpha(surface)) == NULL) {
		SDL_FreeSurface(surface);
		return NULL;
	}
	SDL_FreeSurface(surface);

	return optimized_surface;
}
开发者ID:JonathanWheelhouse,项目名称:jody,代码行数:15,代码来源:surface.c


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