We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › [Solved] copy() puts a black background
Page Index Toggle Pages: 1
[Solved] copy() puts a black background (Read 695 times)
[Solved] copy() puts a black background
Sep 3rd, 2009, 9:18am
 
Hello,

I would like to build a scrolling ticker with bitmap tiles for each letter.

So I load a png picture with letter drawn on a purple background and I use the copy() function to get 32*32px tiles.

The problem is the purple is changed to black.

Could someone please help ?
Re: [Total beginner] copy() puts a black background
Reply #1 - Sep 3rd, 2009, 11:21am
 
Can you show us your code?
Re: [Total beginner] copy() puts a black background
Reply #2 - Sep 3rd, 2009, 11:28am
 
Sorry, here it is :
Code:

//Font sprites
 PGraphics  pg;
 PImage     tickerFontSpriteSheet;
 int  tickerLetterWidth = 32;
 int  tickerLetterHeight = 32;
 int  tickerSpeed = 1;
 
 
 
 
void setup()
{

 size(800,600, P2D);
 frameRate(20);
 background(#330033);
 tickerFontSpriteSheet = loadImage("images/berlin.png");
 pg = createGraphics(800, 600, P2D);



}








void draw()
{  
 
 int i=1;

 pg.beginDraw();
 pg.background(#330033);
 pg.copy(tickerFontSpriteSheet, tickerLetterWidth*i, tickerLetterHeight*i, tickerLetterWidth, tickerLetterHeight,  tickerLetterWidth*i,0, tickerLetterWidth, tickerLetterHeight);
 

 noFill();
   
 pg.endDraw();
 image(pg, 0, 0);
 
}

It seems there is a problem with loops or something because the purple now slowly fades to black.

Re: [Total beginner] copy() puts a black background
Reply #3 - Sep 3rd, 2009, 12:59pm
 
Ah, it is clear now.
copy() says: "No alpha information is used in the process"
You should use image() instead.
Re: [Total beginner] copy() puts a black background
Reply #4 - Sep 3rd, 2009, 7:37pm
 
Thanks a lot, i get it working now Smiley
Page Index Toggle Pages: 1