trying to get an array of every pixel of an image, why is it not working???
when i print pixelArray its just many many 0's. the image file daisy.png is in the same folder as app.java
32 Replies
⌛
This post has been reserved for your question.
Hey @mochatitan! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
doN't catch and ignore exceptions
exceptions have important information on what went wrong
[Ljava.lang.StackTraceElement;@2d8e6db6
what does that mean
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 570 out of bounds for length 570
this message wont stop even when i increase array size or decrease for loop
thanks ill try to figure that out
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
not quite sure why it cant read it though @dan1st | Daniel
maybe the png file is corrupted or something?
that means you did
System.out.println(e.getStackTrace());
instead of e.printStackTrace()
or similar
this means you are accessing a nonexisting elementalright
the error came from the last line (the only one in the try catch)
im wondering if ther was some issue converting it into buffered image
What is your current code and what is the stack trace?
@dan1st | Daniel
Where exactly is the daisy.png file?
Where exactly is it located?
Is it a valid PNG file?
Is there more text in the stack trace?
no that is all
the file would need to be outside the src folder
ah
or you need to access it as a resource
then do i need to do ../daisy.png or something
File
is for external files, not things that are part of the programah
how would i access it now that it is out of the src directory
Stack Overflow
Reading a resource file from within jar
I would like to read a resource from within my jar like so:
File file;
file = new File(getClass().getResource("/file.txt").toURI());
BufferedReader reader = new BufferedReader(new FileRea...
Stack Overflow
How do I load a file from resource folder?
My project has the following structure:
/src/main/java/
/src/main/resources/
/src/test/java/
/src/test/resources/
I have a file in /src/test/resources/test.csv and I want to load the file from a ...
thank you
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
im not using any build tools or eclipse
im just rawdogging it in vscode
i should probably restart in a proper environment
doesn't matter for this issue
if it's in the src folder, you can do
ImageIO.read(App.class.getResource("daisy.png"));
hydra
one bug fixes 2 another one appears
ill try to take it from here though
are you cool if i ping you if i cant figure it out by tomorrow
i have 3 hours of freetime to try
yeah, I'm ok with that
If this post here is marked dormant, it will be reopened if you just send another message here
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.