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


C++ rgba函数代码示例

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


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

示例1: free

bool textureAtlas::load(const std::string &path, bool smooth)
{
    _log::out("Loading texture atlas : %s\n", path.c_str());
    XMLDocument document;

    if(document.LoadFile(path.c_str()))
        return 0;
    free();

    XMLElement *element = document.FirstChildElement("data");
    uint elCount = 0;
    element->QueryAttribute("size", &elCount);
    elements.reserve(elCount);

    if(!texture::load(path.substr(0,path.rfind('/')+1)+element->Attribute("source"), smooth))
        return 0;
    parameteri(GL_TEXTURE_WRAP_S, GL_CLAMP);
    parameteri(GL_TEXTURE_WRAP_T, GL_CLAMP);
    element = element->FirstChildElement("sprite");

    for(int i = 0;element; i++, element = element->NextSiblingElement())
    {
        textureAtlasNode temp;
        temp.angle = 0;
        temp.scale = vec2f(1);
        temp.color = rgba(1);


        CheckAttribute("x", &temp.pos.x, element);
        CheckAttribute("y", &temp.pos.y, element);
        CheckAttribute("w", &temp.size.x, element);
        CheckAttribute("h", &temp.size.y, element);
        CheckAttribute("pX", &temp.center.x, element);
        CheckAttribute("pY", &temp.center.y, element);

        const char *name = element->Attribute("n");
        if(name)
            temp.name = name;
        else _log::out("[WARNING] Can't find attribute \"n\"\n");

        temp.size += vec2f(1);
        elements.push_back(temp);
    }
    _log::out("Elements count: %d\n", elements.size());
    return 1;
}
开发者ID:pelmenka,项目名称:131,代码行数:46,代码来源:atlas.cpp

示例2: main

int
main(int argc, char **argv)
{
  if (argc < 4) {
    std::cerr << "Usage: test_image_rgb_mask " <<
                 "<ifile> <mfile> <ofile> [r] [g] [b]" << std::endl;
    exit(1);
  }

  CFile ifile(argv[1]);
  CFile mfile(argv[2]);
  CFile ofile(argv[3]);

  double r, g, b;

  if (argc >= 5 && ! CStrUtil::toReal(argv[4], &r)) exit(1);
  if (argc >= 6 && ! CStrUtil::toReal(argv[5], &g)) exit(1);
  if (argc >= 7 && ! CStrUtil::toReal(argv[6], &b)) exit(1);

  CImageFileSrc src1(ifile);

  CImagePtr src_image = CImageMgrInst->createImage(src1);

  CImageFileSrc src2(mfile);

  CImagePtr merge_image = CImageMgrInst->createImage(src2);

  CImagePtr merge_image1;

  if (argc >= 5) {
    CRGBA rgba(r, g, b);

    merge_image1 = merge_image->createRGBAMask(rgba);
  }
  else
    merge_image1 = merge_image->createRGBAMask();

  src_image->combineAlpha(merge_image1);

  CFileType type = CFileUtil::getImageTypeFromName(argv[3]);

  src_image->write(&ofile, type);

  exit(0);
}
开发者ID:colinw7,项目名称:CImageLib,代码行数:45,代码来源:test_image_rgb_mask.cpp

示例3: reductionKernel

extern "C" void reductionKernel(const Range& globalID,const Range& localID,const CPUImage<Vec<3,float>>& input,CPUImage<unsigned>& output){
	Vec<3,float> val{ 0,0,0 };
	if(MULTISAMPLING_ENABLED){
		for(int i = 0; i < MULTISAMPLING_SIZE; i++){
			for(int j = 0; j < MULTISAMPLING_SIZE; j++){
				int xpos = globalID.x * MULTISAMPLING_SIZE + i;
				int ypos = globalID.y * MULTISAMPLING_SIZE + j;
				val += input.at(xpos,ypos);
			}
		}
		val /= (MULTISAMPLING_SIZE * MULTISAMPLING_SIZE);
	}else{
		val = input.at(globalID.x,globalID.y);
	}
	Vec<4,uint8_t> rgba(255 * val);
	rgba[3] = 255; //making the color opaque
	output.at(globalID.x,globalID.y) = reinterpret_cast<uint32_t&>(rgba);
}
开发者ID:tly000,项目名称:pipeline,代码行数:18,代码来源:reduction.cpp

示例4: switch

raster::color_t color_utils::fixup_color_for_background(PixelFormat format, raster::color_t color)
{
  switch (format) {
    case IMAGE_RGB:
      if (rgba_geta(color) < 255) {
        return rgba(rgba_getr(color),
                    rgba_getg(color),
                    rgba_getb(color), 255);
      }
      break;
    case IMAGE_GRAYSCALE:
      if (graya_geta(color) < 255) {
        return graya(graya_getv(color), 255);
      }
      break;
  }
  return color;
}
开发者ID:DocHoncho,项目名称:aseprite,代码行数:18,代码来源:color_utils.cpp

示例5: main

int main(int argc, char * argv[])
{
    if (argc < 3) {
        std::cerr<<"usage: "<<argv[0]<<" rgba.tif region.tif"<<std::endl;
        return EXIT_FAILURE;
    }
    gdalwrap::gdal rgba  (argv[1]);
    gdalwrap::gdal region;
    region.names = {"NO_3D_CLASS", "FLAT", "OBSTACLE", "ROUGH"};
    region.copy_meta(rgba, region.names.size());
    color_to_proba(rgba.bands[0], region.get_band("OBSTACLE")); // red
    color_to_proba(rgba.bands[1], region.get_band("FLAT"));     // green
    color_to_proba(rgba.bands[2], region.get_band("ROUGH"));    // blue

    region.save(argv[2]);

    return EXIT_SUCCESS;
}
开发者ID:pierriko,项目名称:gladys,代码行数:18,代码来源:region_from_rgba.cpp

示例6: youmu_common_particle_slice_logic

int youmu_common_particle_slice_logic(Projectile *p, int t) {
    if(t < 0) {
        return 1;
    }

    p->color = rgba(1, 1, 1, 1 - p->args[2]/p->args[0]*20.0);

    if(t < creal(p->args[0])/20.0) {
        p->args[1] += 1;
    }

    if(t > creal(p->args[0])-10) {
        p->args[1] += 3;
        p->args[2] += 1;
    }

    return timeout(p, t);
}
开发者ID:nexAkari,项目名称:taisei,代码行数:18,代码来源:youmu.c

示例7: while

void renderTexture::grapicalPrintf(char* str,   void* fontData, int rasterposx, int rasterposy)
{
    unsigned char c;
    int x = 0;
    int xx = 0;

    while ((c = (unsigned char) * str++))
    {

        x = xx;
        unsigned char* fontPtr = (unsigned char*) fontData;
        char ch = c - 32;

        int sx = ch % 16;
        int sy = ch / 16;


        for (int i = sx * 16; i < (sx * 16 + 16); i++)
        {
            int y = 0;

            for (int j = sy * 16; j < (sy * 16 + 16); j++)
            {
                unsigned char packedColor = (fontPtr[i * 3 + 255 * 256 * 3 - (256 * j) * 3]);
                //float colorf = packedColor ? 0.f : 1.f;
                float colorf = packedColor / 255.f; // ? 0.f : 1.f;
                btVector4 rgba(colorf, colorf, colorf, 1.f);
                //if (colorf)
                {
                    //setPixel(rasterposx+x,rasterposy+y,rgba);
                    addPixel(rasterposx + x, rasterposy + y, rgba);
                }
                //bit >>=1;
                y++;
            }

            x++;
        }

        //xx+=16;
        xx += 10;
    }
}
开发者ID:gkalogiannis,项目名称:simox,代码行数:43,代码来源:RenderTexture.cpp

示例8: Object

Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(OBJECT_SPRITE)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_stock = new Stock(format);
  m_folder = new LayerFolder(this);

  // Generate palette
  Palette pal(FrameNumber(0), ncolors);

  switch (format) {

    // For colored images
    case IMAGE_RGB:
    case IMAGE_INDEXED:
      pal.resize(ncolors);
      break;

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
开发者ID:felipeita,项目名称:aseprite,代码行数:43,代码来源:sprite.cpp

示例9: Object

Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(ObjectType::Sprite)
  , m_document(NULL)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
  , m_frameTags(this)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_folder = new LayerFolder(this);

  // Generate palette
  switch (format) {
    case IMAGE_GRAYSCALE: ncolors = 256; break;
    case IMAGE_BITMAP: ncolors = 2; break;
  }

  Palette pal(frame_t(0), ncolors);

  switch (format) {

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
开发者ID:airways,项目名称:aseprite,代码行数:43,代码来源:sprite.cpp

示例10: create_palette_rek

 // traverse tree and search for nodes with count!=0, that represent single color.
 // clip extreme alfa values
 void create_palette_rek(std::vector<rgba> & palette, node * itr) const
 {
     if (itr->count >= 3)
     {
         unsigned count = itr->count;
         byte a = byte(itr->alphas/float(count));
         if (a > InsertPolicy::MAX_ALPHA) a = 255;
         if (a < InsertPolicy::MIN_ALPHA) a = 0;
         palette.push_back(rgba((byte)round(gamma(itr->reds   / count, gamma_)),
                                (byte)round(gamma(itr->greens / count, gamma_)),
                                (byte)round(gamma(itr->blues  / count, gamma_)), a));
     }
     for (unsigned idx=0; idx < 16; ++idx)
     {
         if (itr->children_[idx] != 0)
         {
             create_palette_rek(palette, itr->children_[idx]);
         }
     }
 }
开发者ID:1060460048,项目名称:mapnik,代码行数:22,代码来源:hextree.hpp

示例11: real

void
shRefract::Shade(const Ray &r, rgba* result) const
{
	rgba Kr;
	mValue->Shade(r, &Kr);
	if (Kr.Luminance() != channel(0.0)) {
		rgba N;
		mCoeficient->Shade(r, &N);

		const real n1 = r.cState.refrN;
		const real n2 = N.Luminance();

		const real n = (r.gState.inside)?(n2/n1):(n1/n2);

		real sin;
		if (n >= real(0.99) && n <= real(0.001)) {
			sin = real(100.0);
		} else {
			sin = real(1.0) - Square(n) * (real(1.0) - Square(r.gState.cosND));
		}


		vec3 refrDir;
		if (n >= real(0.99) && n <= real(0.001)) {
			refrDir = r.dir;
		} else {
			refrDir = r.dir * n + r.gState.normal * (r.gState.cosND * n - sin.Sqrt());
		}


		Ray rayRefr(r.scene, r.gState.point, refrDir, r.cState.depth-1, (r.gState.inside) ? r.parent : &r);
		rayRefr.cState.refrN = n2;
		r.scene->Trace(rayRefr, result);
		if(!r.gState.inside) {
			*result *= Kr;
		}

	} else {
		*result = rgba(0.0);
	}
}
开发者ID:vshymanskyy,项目名称:O_oRT,代码行数:41,代码来源:shRefract.cpp

示例12: rgba

void InfiniteAreaLight::buildDistribution() {
    float ccdf = 0;
    for (int y = 0; y < height; ++y) {
        std::vector<float> row;
        row.reserve(width);

        float cdf = 0;
        for (int x = 0; x < width; ++x) {
            int index = (y * width + x) * 4;
            auto color =
                rgba(data[index + 0], data[index + 1], data[index + 2], 1);
            float w = (color.r + color.g + color.b) / 3.0 + 0.00001;
            cdf += w;
            row.push_back(cdf);
        }

        cdf_columns.push_back(std::move(row));
        ccdf += cdf;
        cdf_rows.push_back(ccdf);
    }
}
开发者ID:jtalbot,项目名称:fungi,代码行数:21,代码来源:light.cpp

示例13: set_current_color

// Changes a color of the current system palette
void set_current_color(int index, int r, int g, int b)
{
  int c;

  ASSERT(index >= 0 && index <= 255);
  ASSERT(r >= 0 && r <= 255);
  ASSERT(g >= 0 && g <= 255);
  ASSERT(b >= 0 && b <= 255);

  c = ase_current_palette->getEntry(index);

  if (rgba_getr(c) != r ||
      rgba_getg(c) != g ||
      rgba_getb(c) != b) {
    RGB rgb;

    ase_current_palette->setEntry(index, rgba(r, g, b, 255));

    rgb.r = r>>2;
    rgb.g = g>>2;
    rgb.b = b>>2;

    set_color(index, &rgb);
  }
开发者ID:Julien-B,项目名称:aseprite,代码行数:25,代码来源:palettes.cpp

示例14: ASSERT

// Creates a linear ramp in the palette.
void Palette::makeGradient(int from, int to)
{
  int r, g, b, a;
  int r1, g1, b1, a1;
  int r2, g2, b2, a2;
  int i, n;

  ASSERT(from >= 0 && from <= 255);
  ASSERT(to >= 0 && to <= 255);

  if (from > to)
    std::swap(from, to);

  n = to - from;
  if (n < 2)
    return;

  r1 = rgba_getr(getEntry(from));
  g1 = rgba_getg(getEntry(from));
  b1 = rgba_getb(getEntry(from));
  a1 = rgba_geta(getEntry(from));

  r2 = rgba_getr(getEntry(to));
  g2 = rgba_getg(getEntry(to));
  b2 = rgba_getb(getEntry(to));
  a2 = rgba_geta(getEntry(to));

  for (i=from+1; i<to; ++i) {
    r = r1 + (r2-r1) * (i-from) / n;
    g = g1 + (g2-g1) * (i-from) / n;
    b = b1 + (b2-b1) * (i-from) / n;
    a = a1 + (a2-a1) * (i-from) / n;

    setEntry(i, rgba(r, g, b, a));
  }
}
开发者ID:rcorre,项目名称:aseprite,代码行数:37,代码来源:palette.cpp

示例15: render_gradient_rect_without_gamma_correction

static void
render_gradient_rect_without_gamma_correction(render_context *ctx, rect2 rect) {
    i32 minx = (i32) (rect.min.x);
    i32 miny = (i32) (rect.min.y);
    i32 maxx = (i32) (rect.max.x);
    i32 maxy = (i32) (rect.max.y);

    if (minx < 0) { minx = 0; }
    if (maxx >= ctx->width) { maxx = ctx->width; }
    if (miny < 0) { miny = 0; }
    if (maxy >= ctx->height) { maxy = ctx->height; }

    u32 *row = ctx->buf + (ctx->height - 1 - miny) * ctx->width + minx;
    i32 size = maxx - minx;
    for (i32 y = miny; y < maxy; ++y) {
        u32 *pixel = row;
        for (i32 x = minx; x < maxx; ++x) {
            f32 intensity = (x - minx) * 1.0f / size;
            u32 color = rgba_to_u32(rgba(intensity, intensity, intensity, 1.0f));
            *pixel++ = color;
        }
        row -= ctx->width;
    }
}
开发者ID:coeuvre,项目名称:breakout,代码行数:24,代码来源:renderer.c


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