Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Picture chromakey(Picture newBg)
- {
- Pixel currPixel=null;
- Pixel newPixel=null;
- Pixel canvas=null;
- Picture result = new Picture(this.getWidth(),this.getHeight());
- for(int x=0; x<getWidth();x++)
- {
- for(int y=0; y<getHeight();y++)
- {
- newPixel=newBg.getPixel(x,y);
- canvas=result.getPixel(x,y);
- canvas.setColor(newPixel.getColor());
- currPixel=this.getPixel(x,y);
- if(currPixel.getRed()+currPixel.getGreen()>currPixel.getBlue())
- {
- canvas.setColor(currPixel.getColor());
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement