示例#1
0
void
PixelGroup::DumpPixMap()
{
	PixMap *pmap = PixMap::GetInstance();
	for (int i=0; i < _num; i++) {
		pmap->AddRGBList(_key);
	}
}
示例#2
0
void PixMap::copy(const PixMap& pix) {
    if (size() != pix.size()) {
        throw Exception("Mismatch in PixMap sizes");
    }
    for (int i = 0; i < size().height; ++i) {
        memcpy(mutable_row(i), pix.row(i), size().width * sizeof(RgbColor));
    }
}
示例#3
0
/*this fill function is currently a stub (function that compiles and operates
  in some expected manner but doesn't actually work).  It only fills in the top left 10x10 pixel
area with the fill colour passed in and its return value is always true
*/
bool fill(PixMap& image,const Pixel& fillColour,int x, int y){
	if (image.getPixel(x, y) == fillColour) {
		image.setPixel(fillColour, x, y);

		return true;
	}
	image.setPixel(fillColour, x, y);
	if(x < image.width()-1){
	fill(image, fillColour, x+1, y);
	}
	if(x > 0){
	fill(image, fillColour, x-1, y);
	}
	if(y < image.height()-1 ){
	fill(image, fillColour, x, y + 1);
	}
	if(y > 0){
	fill(image, fillColour, x, y - 1);
	}
	return true;

}
示例#4
0
void PixMap::composite(const PixMap& pix) {
    if (size() != pix.size()) {
        throw Exception("Mismatch in PixMap sizes");
    }
    for (int y = 0; y < size().height; ++y) {
        for (int x = 0; x < size().width; ++x) {
            const RgbColor& over = pix.get(x, y);
            const double oa = over.alpha / 255.0;
            const RgbColor& under = get(x, y);
            const double ua = under.alpha / 255.0;

            // TODO(sfiera): if we're going to do anything like this in the long run, we should
            // require that alpha be pre-multiplied with the color components.  We should probably
            // also use integral arithmetic.
            double red   = (over.red   * oa) + ((under.red   * ua) * (1.0 - oa));
            double green = (over.green * oa) + ((under.green * ua) * (1.0 - oa));
            double blue  = (over.blue  * oa) + ((under.blue  * ua) * (1.0 - oa));
            double alpha = oa + (ua * (1.0 - oa));
            set(x, y, RgbColor(alpha * 255, red / alpha, green / alpha, blue / alpha));
        }
    }
}
示例#5
0
void NatePixTable::Frame::load_overlay(const PixMap& pix, uint8_t color) {
    for (auto x : range(width())) {
        for (auto y : range(height())) {
            RgbColor over  = pix.get(x, y);
            uint8_t  value = over.red;
            uint8_t  frac  = over.alpha;
            over           = RgbColor::tint(color, value);
            RgbColor under = _pix_map.get(x, y);
            RgbColor composite;
            composite.red   = ((over.red * frac) + (under.red * (255 - frac))) / 255;
            composite.green = ((over.green * frac) + (under.green * (255 - frac))) / 255;
            composite.blue  = ((over.blue * frac) + (under.blue * (255 - frac))) / 255;
            composite.alpha = under.alpha;
            _pix_map.set(x, y, composite);
        }
    }
}
示例#6
0
void copy_world(PixMap& to, PixMap& from, Rect bounds) {
    bounds.clip_to(to.size().as_rect());
    to.view(bounds).copy(from.view(bounds));
}
shared_ptr<Texture> TextureManager::createTexture(const PixMap &map, TexFlags flags) {
	SDL_Surface *img = SDL_CreateRGBSurfaceFrom(const_cast<PixMap::pixel_t *>(map.getData()), map.getWidth(), map.getHeight(), 32, map.getWidth()*4, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
	
	return surfaceToTexture(logger, img, renderer, flags, "#PIXMAP");
}