• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pixel函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: get_extrema

void FloatImage::write_pgm(char *filename, float mini, float maxi)
{
  int i,j;
  int count = xsize * ysize;

  /* maybe find minimum and maximum values */

  float min = mini;
  float max = maxi;

  if (min == 0 && max == 0) {

    get_extrema (min, max);

    if (max == min)
      min = max - 1;
  }

  unsigned char *image_data;
  image_data = new unsigned char [count];

  for (j = 0; j < ysize; j++)
    for (i = 0; i < xsize; i++) {

      int val = (int) (255 * (pixel(i,j) - min) / (max - min));

      /* clamp values */
      if (val < 0) val = 0;
      if (val > 255) val = 255;
      image_data[i+j*xsize] = val;
    }

  int fd = open(filename, O_CREAT|O_TRUNC|O_WRONLY, 0666);
  if (fd < 0) {
    fprintf(stderr, "Unable to open %s: %s\n", filename, strerror(errno));
    exit(-1);
  }

  char str[80];
  sprintf (str, "P5\n%d %d\n255\n", xsize, ysize);
  int cc = write(fd, str, strlen(str));
  if (cc == -1) {
    fprintf (stderr, "Can't write to file.\n");
    exit (-1);
  }

  cc = write(fd, image_data, sizeof(unsigned char) * xsize * ysize);

  if (cc != sizeof(unsigned char) * xsize * ysize) {
    fprintf(stderr, "Write returned short: %s\n", strerror(errno));
    close(fd);
    exit(-1);
  }

  close(fd);
}
开发者ID:haolly,项目名称:fluid3dsjtu,代码行数:56,代码来源:FloatImage.cpp


示例2: pixel

void Bitmap::premultiplyAlpha()
{
  if(!premultiplied)
  {
    for(uint32_t x=0; x<width; ++x)
    {
      for(uint32_t y=0; y<height; ++y)
      {
        common::Color c = pixel(x,y);
        float a = c.fv[3];
        c.fv[0] = c.fv[0]*a;
        c.fv[1] = c.fv[1]*a;
        c.fv[2] = c.fv[2]*a;
        pixel(x,y,c);
      }
    }
    premultiplied = true;
  }
}
开发者ID:Wednesnight,项目名称:lostengine,代码行数:19,代码来源:Bitmap.cpp


示例3: ShowSubdiv

void ShowSubdiv(HWND hw)
{
	HDC	dc = GetDC	(hw);

	u32 CB = RGB(255,0,0);
	for (int z=0; z<dimZ; z++)
	{
		for (int x=0; x<dimX; x++)
		{
			Texel&	T	= texels[z*dimX+x];
			if (T.N)	{
				pixel	(dc,x,z,RGB(127,127,127));
				vertex&	N = *T.N;

				int		_x=x*3,_y=z*3;
				if		(isBorder(N,0))	{		// left
					SetPixel(dc,_x,_y+0,CB);
					SetPixel(dc,_x,_y+1,CB);
					SetPixel(dc,_x,_y+2,CB);
				}
				if		(isBorder(N,1))	{		// fwd
					SetPixel(dc,_x+0,_y,CB);
					SetPixel(dc,_x+1,_y,CB);
					SetPixel(dc,_x+2,_y,CB);
				}
				if		(isBorder(N,2))	{		// right
					SetPixel(dc,_x+2,_y+0,CB);
					SetPixel(dc,_x+2,_y+1,CB);
					SetPixel(dc,_x+2,_y+2,CB);
				}
				if		(isBorder(N,3))	{		// back
					SetPixel(dc,_x+0,_y+2,CB);
					SetPixel(dc,_x+1,_y+2,CB);
					SetPixel(dc,_x+2,_y+2,CB);
				}
			} else {
				pixel	(dc,x,z,RGB(0,127,0));
			}
		}
	}

	ReleaseDC		(hw, dc);
}
开发者ID:2asoft,项目名称:xray,代码行数:43,代码来源:compiler_display.cpp


示例4: clear

int clear(int sx, int sy, int ex, int ey)
{
	for(int j=sy; j<ey; j++)
	{
		for(int i=sx; i<ex; i++)
		{
			pixel(i, j, 0, 0, 0);
		}
	}
}
开发者ID:emilfihlman,项目名称:fbpuukottaja,代码行数:10,代码来源:fbpuukk.c


示例5: GEODE_ASSERT

Array<Vector<T,3>,2> Image<T>::median(const vector<Array<const Vector<T,3>,2> >& images) {
  GEODE_ASSERT(images.size());
  int n = (int)images.size();
  for (int k=1;k<n;k++)
    GEODE_ASSERT(images[0].sizes()==images[k].sizes());

  Array<T,2> pixel(3,n);
  Array<Vector<T,3>,2> result(images[0].sizes());
  for(int t=0; t<result.flat.size(); t++){
    for (int k=0;k<n;k++)
      images[k].flat[t].get(pixel(0,k),pixel(1,k),pixel(2,k));
    for (int a=0;a<3;a++) {
      RawArray<T> samples = pixel[a];
      nth_element(&samples[0],&samples[n/2],&samples[n-1]);
      result.flat[t][a] = samples[n/2];
    }
  }
  return result;
}
开发者ID:Haider-BA,项目名称:geode,代码行数:19,代码来源:Image.cpp


示例6: qDebug

void Utility::Yuv422FileSaver::savePacked() {
	for(std::size_t k=0; k<video_->getNumberOfFrames()&&isRunning_; k++) {
		auto frame=video_->getFrame(k);
		for(int i=0; i<width_*height_; i+=2) {
			int y1=i/width_;
			int x1=i%width_;
			int y2=(i+1)/width_;
			int x2=(i+1)%width_;

			if(!frame->valid(x1,y1)||!frame->valid(x2,y2)) {
				qDebug()<<"Wrong pixel coordinates";
				continue;
			}

			auto vec=Rgb888ToYuv422(frame->pixel(x1,y1),frame->pixel(x2,y2));
			dataStream_<<vec.getU()<<vec.getY1()<<vec.getV()<<vec.getY2();
		}
	}
}
开发者ID:SuppenGeist,项目名称:pse-ws1516-videoencoder-ta,代码行数:19,代码来源:Yuv422FileSaver.cpp


示例7: copyToLedsArray

 void copyToLedsArray(uint8_t (*state)[WIDTH][HEIGHT]) {
     for (int x = 0; x < WIDTH; x++) {
         for (int y = 0; y < HEIGHT; y++) {
             uint8_t hugh = (*state)[x][y];
             if (hugh > 0) {
                 pixel(x, y) = CHSV(hugh, 255, 255);
             }
         }
     }      
 }
开发者ID:SigmazGFX,项目名称:TechnicolorDreamcoat2014,代码行数:10,代码来源:Life.cpp


示例8:

/// Allow access to these pixels.
void asf::parameter_float_image::pixel_setsize(const pixel_rectangle &pixel_meta,int zoom_meta)
{
	super::pixel_setsize(pixel_meta,zoom_meta);
	int new_dx=bands(), new_dy=bands()*pixel().size_x();
	if ((data!=0) && (new_dx==xd) && (new_dy==yd))
		{ /* then re-use existing buffer--it's still OK. */ }
	else { /* Have to allocate a new buffer */
		data_alloc(src_alloc,0,new_dx,new_dy);
	}
}
开发者ID:DavinSimmons,项目名称:ASF_MapReady,代码行数:11,代码来源:image.cpp


示例9: mycircle

void mycircle(int a,int b,int r,int c)
{
    int p=1-r,x=0,y=r;
    pixel(a,b,x,y,c);
    while(x<y)
    {
      if(p<0)
      {
      x++;
      p=p+(2*x)+1;
      }
      else
      {
      x++;
      y--;
      p=p+(2*x)-(2*y)+1;
      }
      pixel(a,b,x,y,c);
  }
}
开发者ID:mintoo511,项目名称:Moving-Car-in-CPP-graphics,代码行数:20,代码来源:movingCar.cpp


示例10: spinHue

void spinHue(void) {
  static float angle = 0.0f;
  angle += 0.001;
  if (angle > PI * 2) angle -= PI * 2;
  
  pixel(
      64.0f * (sin(angle + circleThird(0)) + 1.0f),
      64.0f * (sin(angle + circleThird(1)) + 1.0f),
      64.0f * (sin(angle + circleThird(2)) + 1.0f)
    );
}
开发者ID:Bluebie,项目名称:avr-toys,代码行数:11,代码来源:glass-lamp.c


示例11: base

	Rect CoordConverter::screenToWindow(const Window& window, const URect& rect)
	{
		Vector2 base(getBaseValue(window));
		Rect pixel(rect.asAbsolute(System::getSingleton().getRenderer()->getSize()));

		// negate base position
		base.d_x = -base.d_x;
		base.d_y = -base.d_y;

		return pixel.offset(base);
	}
开发者ID:chenbk85,项目名称:3dlearn,代码行数:11,代码来源:ELGUICoordConverter.cpp


示例12: drawcircle

static void drawcircle(uint8_t *data, int width) {
    int x, y;
    double hw = (double)width / 2.0 - 0.5;
    for(y = 0; y != width; y++) {
        for(x = 0; x != width; x++) {
            double dx = (x - hw), dy = (y - hw);
            double d = sqrt(dx * dx  + dy * dy) - hw + 0.5;
            *data++ = pixel(d);
        }
    }
}
开发者ID:Chuongv,项目名称:uTox,代码行数:11,代码来源:svg.c


示例13: vga_fill

void vga_fill(int w, int h, int x, int y, int c)
{
    int tx,ty;
    
    for(ty = y; ty < y+h; ty++){
        for(tx = x; tx < x+w; tx++){
            pixel(tx,ty,c);
        }
    }

}
开发者ID:danilaslau,项目名称:frotznet,代码行数:11,代码来源:vga.c


示例14: noise

int noise(void)
{
	for(int j=96; j<yres; j++)
	{
		for(int i=0; i<xres; i++)
		{
			char r=rand()>>23-1;
			pixel(i, j, r, r, r);
		}
	}
}
开发者ID:emilfihlman,项目名称:fbpuukottaja,代码行数:11,代码来源:fbpuukk.c


示例15: free_color

      void free_color()
	{
	  unsigned long pixels[2];
	  pixels[0] = pixel();

	  XFreeColors ( m_display,
			m_map,
			pixels,
			1,
			0 );
	}
开发者ID:8l,项目名称:x11,代码行数:11,代码来源:color.hpp


示例16: vga_fill_grad

void vga_fill_grad(int w, int h, int x, int y)
{
    int tx,ty;
    
    for(ty = y; ty < y+h; ty++){
        for(tx = x; tx < x+w; tx++){
            pixel(tx,ty,128 + ty/4);
        }
    }

}
开发者ID:danilaslau,项目名称:frotznet,代码行数:11,代码来源:vga.c


示例17: pixel

void Picasso::circle (unsigned int x, unsigned int y, unsigned int r) {
  float rads = 0;
  
  for(float da = 1; da <= 360; da++) {
    rads = da / 180 * 3.14;
    
    pixel(
      x + (unsigned int)(cos(rads) * r),
      y + (unsigned int)(sin(rads) * r)
    );
  }
};
开发者ID:mjurczyk,项目名称:eve,代码行数:12,代码来源:Picasso.cpp


示例18: drawcross

static void drawcross(uint8_t *data, int width) {
    int x, y;
    double hw = 0.5 * (double)(width - 1);
    double w = 0.0625 * (double)width;
    for(y = 0; y != width; y++) {
        for(x = 0; x != width; x++) {
            double dx = fabs(x - hw), dy = fabs(y - hw);
            double d = fmin(dx, dy) - w;
            *data++ = pixel(d);
        }
    }
}
开发者ID:Chuongv,项目名称:uTox,代码行数:12,代码来源:svg.c


示例19: result

lost::shared_ptr<Bitmap> Bitmap::rotCW()
{
  shared_ptr<Bitmap> result(new Bitmap(height, width, COMPONENTS_RGBA));
  for(uint32_t y=0; y<height; ++y)
  {
    for(uint32_t x=0; x<width; ++x)
    {
      result->pixel(y, x, pixel((width-1)-x,y));
    }
  }
  return result;
}
开发者ID:Wednesnight,项目名称:lostengine,代码行数:12,代码来源:Bitmap.cpp


示例20: base

//----------------------------------------------------------------------------//
Rectf CoordConverter::screenToWindow(const Window& window, const URect& rect)
{
    Vector2f base(getBaseValue(window));
    Rectf pixel(asAbsolute(rect, window.getRootContainerSize()));

    // negate base position
    base.d_x = -base.d_x;
    base.d_y = -base.d_y;

    pixel.offset(base);
    return pixel;
}
开发者ID:AjaxWang1989,项目名称:cegui,代码行数:13,代码来源:CoordConverter.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pixelType函数代码示例发布时间:2022-05-30
下一篇:
C++ pixcmapGetCount函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap