Пример #1
0
bool OverlayEffect::draw(ImageOf<PixelRgb>& src2, ImageOf<PixelRgb>& dest2) {
  if (needRead) {
    readEffectData();
    needRead = false;
  }
  dest2 = src2;

  if (img.isValid()) {
    for (int x=0; x<dest2.width()&&x<img.width(); x++) {
      for (int y=0; y<dest2.height()&&y<img.height(); y++) {
	PixelBgra v = img.pixel(x,y);
	if (v.a==0) {
	  dest2(x,y) = PixelRgb(v.r,v.g,v.b);
	} else if (v.a>=127) {
	  // do nothing, leave copied value
	} else {
	  PixelRgb& o = dest2(x,y);
	  float f = v.a/127.0;
	  if (f>1) f = 1;
	  int r = (int)((1-f)*v.r+f*o.r);
	  int g = (int)((1-f)*v.g+f*o.g);
	  int b = (int)((1-f)*v.b+f*o.b);
	  dest2(x,y) = PixelRgb(r,g,b);
	}
      }
    }
  }


  return true;
}
Пример #2
0
void OverlayEffect::readEffectData() {
  if (workOverlay!="") {
    if (workOverlay!=readOverlay) {
      img.load(workOverlay.c_str());
      printf("overlay size %dx%d\n", img.width(), img.height());
      readOverlay = workOverlay;
    }
  }
}
Пример #3
0
 Assets::Texture* Md2Parser::loadTexture(const Md2Skin& skin) {
     const Path skinPath(String(skin.name));
     MappedFile::Ptr file = m_fs.openFile(skinPath);
     
     Color avgColor;
     const ImageLoader image(ImageLoader::PCX, file->begin(), file->end());
     
     const Buffer<unsigned char>& indices = image.indices();
     Buffer<unsigned char> rgbImage(indices.size() * 3);
     m_palette.indexedToRgb(indices, indices.size(), rgbImage, avgColor);
     
     return new Assets::Texture(skin.name, image.width(), image.height(), avgColor, rgbImage);
 }