本文整理汇总了C++中sf::Image::SetPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ Image::SetPixel方法的具体用法?C++ Image::SetPixel怎么用?C++ Image::SetPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Image
的用法示例。
在下文中一共展示了Image::SetPixel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: swapImg
void Terrain::swapImg(sf::Image &img)
{
for(unsigned int i=0;i<img.GetWidth();i++)
{
for(unsigned int j=0;j<img.GetHeight()/2;j++)
{
sf::Color tmp = img.GetPixel(i,img.GetHeight()-1-j);
img.SetPixel(i,img.GetHeight()-1-j,img.GetPixel(i,j));
img.SetPixel(i,j,tmp);
}
}
}
示例2: draw
void ColorScale::draw(sf::Image& img,const sf::Vector2f& start,const sf::Vector2f& end,GradientStyle::GradientStyle style, int size) const
{
sf::Color (*pFunction)(sf::Color*,int,const sf::Vector2f&,const sf::Vector2f&,int,int);
sf::Color* tab =new sf::Color[size];
fillTab(tab,size);
switch (style)
{
case GradientStyle::Linear : pFunction = GradientLinear; break;
case GradientStyle::Circle : pFunction = GradientCircle; break;
case GradientStyle::Radial : pFunction = GradientRadial; break;
case GradientStyle::Reflex : pFunction = GradientReflex; break;
default: pFunction = GradientLinear; break;
}
for(int i=0;i<img.GetWidth();i++)
{
for(int j=0;j<img.GetHeight();j++)
{
img.SetPixel(i,j,pFunction(tab,size,start,end,i,j));
}
}
delete[] tab;
}
示例3: DrawCharacter
void DrawCharacter(sf::Image &screen, unsigned short *font_buff, char c, sf::Color fg_col, sf::Color bg_col, bool blink, int x, int y)
{
/*
set the area on the screen to the proper character c, defined in the font_buf
use the colors fg_col and bg_col
fonts defined in 2 words
upperword aaaa bbbb cccc dddd
lowerword eeee ffff gggg hhhh
character defined as
a a a a
b b b b
c c c c
d d d d
e e e e
f f f f
g g g g
h h h h
1 means set to fg_col, 0 means set to bg col
*/
int font_off_x = x * 4;
int font_off_y = y * 8;
//font_buff += (c * 2); // 1 char per word
unsigned short fontupperword = font_buff[(c * 2)];
unsigned short fontlowerword = font_buff[(c * 2) + 1];
unsigned int font_char = fontupperword << 16 | fontlowerword;
//for(int off = 0; off < 32; off++) // for reverse
for(int off = 31; off >= 0; off--)
{
unsigned int mask = font_char & (1 << (31-off));
int x_img = font_off_x + (off % 4);
int y_img = font_off_y + (off / 4);
if(mask > 0 && !blink)
screen.SetPixel(x_img, y_img, fg_col);
else
screen.SetPixel(x_img, y_img, bg_col);
}
}
示例4: SetPixelWithVariance
void SetPixelWithVariance(int r, int g, int b, int x, int y, int variance, sf::Image &Image)
{
int br, bg, bb;
br=r*variance;
bg=g*variance;
bb=b*variance;
if(br>255) {
br=255;
}
if(br<0) {
br=0;
}
if(bg>255) {
bg=255;
}
if(br<0) {
bg=0;
}
if(bb>255) {
bb=255;
}
if(br<0) {
bb=0;
}
sf::Color Temp;
Temp.r=br;
Temp.g=bg;
Temp.b=bb;
Image.SetPixel(x, y, Temp);
}
示例5: Render
void Metl::Render(sf::Image& pixbuff)
{
pixbuff.SetPixel(XPos,YPos,sf::Color::Red);
}