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 › lingo user having some problems with images
Page Index Toggle Pages: 1
lingo user having some problems with images (Read 958 times)
lingo user having some problems with images
Jul 19th, 2005, 4:59pm
 
hi, guys.
I know this might look stupid, but I couldn't figure out a very simple (at least in lingo) operation on images.

I create new PImage objects, but then it doesn't allow me to perform any operation on them.

for example:
how can i draw a line on a PImage object?
I noticed that all the documentation I can find around, makes operations on the screen image.

what if I want to create my own stuff in a buffer and only when I have what I want project it using image(sourceImage,x,y)?

please, help me out with this.

besides...
is there any reference with examples and other?
I find the site reference a bit weak.
sorry for complains, but I'm a very bad guy

Smiley

ciao.ubi

ps: I love what this software can do, and since director/lingo proves always slower and slower, I need to learn it to replace the old IDE
besides: flash sucks
Re: lingo user having some problems with images
Reply #1 - Jul 19th, 2005, 9:03pm
 
You can create your own using:

[/code]
PGraphics buf;

setup() {

buf = new PGraphics(x,y,null);
buf.defaults();
buf.background(255);
buf.stroke(0);
buf.line(x1,y1,x2,y2);
}
[/code]

Obviously you'd stick all your drawing stuff in draw(), but beware that not all functionality is available using your own BGraphics obj's. as I've been learning today.

http://processing.org/discourse/yabb_beta/YaBB.cgi?board=Programs;action=display;num=1121781388;start=0#2

image(buf,0.0); will drop your buffer to the display window

There are alternatives PGraphics2 and 3, that might improve things. Ben says this sort of thing is on the list, given the number of users programming in this way.

I'm just beginning to get some space to explore 91 further, but still think in 68 so forgive any syntactical slip ups
Re: lingo user having some problems with images
Reply #2 - Jul 19th, 2005, 11:15pm
 
hey, mark
u actually made my processing day!

I got to the point of using PGraphics, but I couldn't have anything work.
not even .background()

I was missing the damn defaults()

well...
I had to use PGraphics3 in order to have .line() work on an image object

but now a lot changed.
do you know if PGraphics2 and 3 simply extend the PGraphics class?
well...
probably I can go check myself the source, but i'm a very bad java programmer (I know nothing about it)

thanx for your GREAT help

ciao.ubi
Re: lingo user having some problems with images
Reply #3 - Jul 19th, 2005, 11:24pm
 
Yeah, the defaults bit had me screwed for a while.

Not sure about the extends PGraphics. I haven't looked at the source for a while, though in light of my trouble I'm gonna have to, as my code just sits and glares doing S.F.A

Saying that though they are (castable).

OOP is not my forte
Re: lingo user having some problems with images
Reply #4 - Jul 20th, 2005, 11:22am
 
ok...
more problems to come.

what I got so far is the ability to draw on an image object declaring it as a PGraphics3 object.

my little one is this


PGraphics3 bfr;
PImage extImg;
color blk=color(0,0,0);
void setup()
{
 size(200, 200);
 framerate(30);
 bfr=new PGraphics3(320,240,null);
 extImg=loadImage("test.gif");
 background(127,255,121);
 bfr.stroke(255);
 bfr.background(127,255,121);
 bfr.set(10,10,blk);
 bfr.set(100,10,blk);
 bfr.set(100,100,blk);
 bfr.set(10,100,blk);
}

void draw()
{
 int mx=mouseX;
 int my=mouseY;
 bfr.line(150,150,mx,my);
 image(extImg,0,0);
 line(0,0,mx,my);
 image(bfr,10,10);
}


and it doesn't allow for runtime [draw()] drawing on the object.
the only thing I can do is draw over it during setup.

hope somebody can sort this out

Re: lingo user having some problems with images
Reply #5 - Jul 20th, 2005, 3:21pm
 


The PGraphics3 is throwing a null pointer exception.

I'm gonna have a poke around, as it's the same problem I had yesterday.
Re: lingo user having some problems with images
Reply #6 - Jul 20th, 2005, 3:30pm
 
Try this!

I've commented out your first image() just for speed my end, and the copy needs to obviously contain the right size parameters, again width and height used for speed, but you'd change them to me.width etc;

Seems casting the P3 as a P does the trick

Code:


void draw()  
{  
 int mx=mouseX;
 int my=mouseY;
 bfr.line(150,150,mx,my);
//  image(extImg,0,0);
 line(0,0,mx,my);
 
 PGraphics me= (PGraphics)bfr;

 copy(me,0,0,width,height,0,0,width,height);

}


This takes care of the problem  for both of us, I hope!
Re: lingo user having some problems with images
Reply #7 - Jul 20th, 2005, 3:51pm
 
Sorry, talking crap. You don't need a cast at all, just a copy instead of image(bfr);

Code:

copy(bfr,0,0,width,height,0,0,width,height);


Come to think of it, it's not the first time I've encountered this activity with image. I wonder if its got anything to do with the alpha channel?
Re: lingo user having some problems with images
Reply #8 - Jul 23rd, 2005, 4:17pm
 
hey, mark.
sorry for the delay.
I was on a deadline and had a pretty hard time to even check emails.
last night (tired as hell) I checked the board and found your post.
immediately gave it a try.

no big change.

here's what I have so far

PGraphics3 bfr;
PImage extImg;
color blk=color(0,0,0);
void setup()
{
 size(200, 200);
 framerate(30);
 bfr=new PGraphics3(320,240,null);
 extImg=loadImage("test.gif");
 background(127,255,121);
 stroke(255,0,0,100);
 bfr.stroke(255,0,0,255);
 bfr.background(127,255,121);
 bfr.set(10,10,blk);
 bfr.set(100,10,blk);
 bfr.set(100,100,blk);
 bfr.set(10,100,blk);
 //bfr.image(extImg,0,0);
}

void draw()
{
 int mx=mouseX;
 int my=mouseY;
 bfr.line(200,200,mx,my);
 //copy(bfr,0,0,width,height,0,0,width,height);
 line(0,0,mx,my);
}

check the commented lines, please.

if we uncomment the first one (in the setup) we can have a graphic on bfr.
but then, when executing a line over it

bfr.line(200,200,mx,my);

we get a weird result.
if you try staying still on the image, then you realize that the line is drawn cycle by cycle.
this means that we have a low opacity (alpha) on the stroke.
setting a different stroke, doesn't change much.
if we uncomment the second commented line

copy(bfr,0,0,width,height,0,0,width,height);

then we can't see any result, cause the line is drawn with low opacity, but at the next cycle it's covered by the bfr base image again.

this means that fixes are needed on the stroke method over PGraphics3 objects.

by the way...
thanx a lot for you efforts, mark.

:)

Page Index Toggle Pages: 1