FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   simple java vs p5 q...regarding getImage
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: simple java vs p5 q...regarding getImage  (Read 534 times)
sinkblot

sinkblot
simple java vs p5 q...regarding getImage
« on: Apr 28th, 2004, 1:43pm »

Hello again -  I was trying to write a sketch that automatically scans and loads images placed in subdirs - spend several hours [I'm new] figuring out the java syntax for properly identifying the directories and setting it up, before I realized that p5 only loads data in the sketch folder - so I read up on the getImage function but when I load my .jpg it tells me that it is an inappropriate dataype for BImage.  [i should mention that I used the java syntax:
 
Image[] imgs; to set up my image array.]
 
I'm still dipping my toes in the java pool, is there something I'm missing, or perhaps an alternate way to load an image from a String, URL, or other?
 
Thanks a million
 
sinkblot

sinkblot
Re: simple java vs p5 q...regarding getImage
« Reply #1 on: Apr 28th, 2004, 1:55pm »

I should add that the specific error I get is:
oh, I forgot, I can't copy out of the console.  Here's the meat.
Semantic Error: the type of the right sub-expression, "java.awt.Image", is not assignable to the variable, of type "BImage"
 
arielm

WWW
Re: simple java vs p5 q...regarding getImage
« Reply #2 on: Apr 28th, 2004, 3:40pm »

your problem could be related to the issue described here:
http://processing.org/discourse/yabb/board_Syntax_action_displa_y_num_1070907373.html
 

Ariel Malka | www.chronotext.org
sinkblot

sinkblot
Re: simple java vs p5 q...regarding getImage
« Reply #3 on: Apr 29th, 2004, 5:27am »

it is related... but the methods suggested don't seem to work for me... that is, the modified lib file did seem to work, but still was unable to load an image from a path.  I was attempting a workaround by loading a string into an URL and then using that to load the image... with some obscure errors such as "; inserted to complete block statements".
 
Either that or the URL came out as "null."
 
This is eventually going to be online anyway, so I guess it's not that important, as I can just use a straight URL type.  The real point of this thing was to automatically scan a folder, create button-objects for each folder, and thumbnail objects for everything inside each folder.  I want to automate my portfolio web image processing, basically.  Anyone else feel that this is a good idea?
 
The lengths the lazy go to.  Heh.  Thanks for the help, though.
 
sinkblot

sinkblot
Re: simple java vs p5 q...regarding getImage
« Reply #4 on: Apr 30th, 2004, 7:46am »

Okay, according to a post by toxi - loadImage can load a picture if you give it an absolute path (as a string, I believe), the example she gives was something like loadImage("c:/processing etc....image.tga".
 
Was this only applicable to the custom targa reader she made, or is this something that loadImage is just supposed to do?
 
I tried a small dummy program with just
//------
 BImage img=loadImage("/pics/c/c01.jpg");
image(img,0,0,100,100);
//---
 
and also no luck.
I've tried absolute path, relative path, f.getAbsolutePath() and all sorts of string combinations with even more no luck.  I repaired disk permissions, tried loading stuff from different volumes, made sure there were no wierd characters in the path... yes.
 
I'm just trying to load some .jpgs and .gifs, here... but I don't want to de-categorize them all into the data directory.
 
so, is something wrong with my implementation of loadImage, or was I mistaken about this capability?  If so, does anyone know a java command to do the same?  It seems silly that this would be so much trouble.
 
If you want to look at the code, let me know - it's somewhat bloated for purposes of this q .  Thanks always.
 
toxi_
Guest
Email
Re: simple java vs p5 q...regarding getImage
« Reply #5 on: Apr 30th, 2004, 12:50pm »

sinkblot, i was not sure about absolute (local) filenames for loadImage() when i wrote about them a while ago. now i am. looks like filenames in loadImage() are only checked for an URL ("http://..."). otherwise the file is assumed to be in the /data directory. you're right, this is something we should change, also because loadBytes(), openStream() etc. don't behave like that. with those you can read any file..
 
btw. sorry, but this also had to be said...
 
fry


WWW
Re: simple java vs p5 q...regarding getImage
« Reply #6 on: Apr 30th, 2004, 5:34pm »

yep, i've had a note on the todo list to make loadImage() use the same logic for opening files as openStream and the rest. i'll bump that up for 70.
 
sinkblot

sinkblot
Re: simple java vs p5 q...regarding getImage
« Reply #7 on: Apr 30th, 2004, 10:06pm »

Thanks always for the info...
 couple of followup Q's.  
 
I really wanted to use local images to cut down on writing/debugging time [much quicker than compiling program, uploading to server, running from browser], but barring a good java implementation to accomplish the same thing, has anyone had luck using a localhost to trick processing?  In osX you can load up safari and enter "0" [zero] as an URL and use some obscure library directory as a faux website.  I have had little luck, but will keep all posted.
 
Also on a side note, this project came out of an attempt to write a program to map out a whole harddrive as an extremely large and high-resolution image... but I guess those questions should go to a java forum.
 
and an apology- I assumed you were female, but only because your name ended in an i.  I have a prejudice I never even knew about!  Will do my pronoun homework in the future.
« Last Edit: Apr 30th, 2004, 10:08pm by sinkblot »  
Pages: 1 

« Previous topic | Next topic »