Comments (6)
Not having my tablet in front of me, I believe the error might be with you accessing the image's pixels. While you can do this the way you have it in the desktop version, if memory serves the Android mode will cause an NPE if you don't include img.loadPixels() and img.updatePixels() first.
from processing-android-archive.
I have chosen the example so no external file is needed, however if the image is created using the loadImage() method (and pixels are not accessed), the crash occurs as well. E.g. extension of the LoadDisplayImage example:
PImage img; // Declare variable "a" of type PImage
void setup() {
size(640, 360);
// The image file must be in the data folder of the current sketch
// to load successfully
img = loadImage("moonwalk.jpg"); // Load the image into the program
img.resize(100,100);
}
void draw() {
// Displays the image at its actual size at point (0,0)
image(img, 0, 0);
// Displays the image at point (0, height/2) at half of its size
image(img, 0, height/2, img.width/2, img.height/2);
}
crashes with:
FATAL EXCEPTION: Animation Thread
java.lang.NullPointerException
at android.graphics.Bitmap.checkPixelsAccess(Bitmap.java:834)
at android.graphics.Bitmap.setPixels(Bitmap.java:892)
at processing.core.PGraphicsAndroid2D.imageImpl(Unknown Source)
at processing.core.PGraphics.image(Unknown Source)
at processing.core.PApplet.image(Unknown Source)
at processing.test.loaddisplayimage.LoadDisplayImage.draw(LoadDisplayImage.java:41)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PGraphicsAndroid2D.requestDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
at java.lang.Thread.run(Thread.java:1019)
But, actually, based on your suggestion I have tried adding pixel manipulation methods to the code and the following version (img.loadPixels() is added after resize) works:
PImage img; // Declare variable "a" of type PImage
void setup() {
size(640, 360);
// The image file must be in the data folder of the current sketch
// to load successfully
img = loadImage("moonwalk.jpg"); // Load the image into the program
img.resize(100,100);
img.loadPixels();
}
void draw() {
// Displays the image at its actual size at point (0,0)
image(img, 0, 0);
// Displays the image at point (0, height/2) at half of its size
image(img, 0, height/2, img.width/2, img.height/2);
}
I am not familiar with method Processing internally works with images, but I assume that the requirement the explicit call of img.loadPixels() is not intentional.
from processing-android-archive.
Duplicate of #22.
from processing-android-archive.
why it is closed ? i didn't find the solution for this resize() problem. i just got the same issue.
from processing-android-archive.
It's not really closed as in fixed, it's closed as a duplicate. The report is still open at #22.
from processing-android-archive.
Actually, it's processing/processing-android#21; this repository is archived.
from processing-android-archive.
Related Issues (20)
- PVector.set(float float) method does not exist as it should according to documentation and java mode HOT 3
- curveVertex bug HOT 4
- PShape getVertex() not implemented properly for SVG files HOT 1
- back button causes app shutdown with no call to keyPressed() or onPause() HOT 5
- "Build failed" on example code (Arch Linux x64) HOT 3
- 'Processing & Android: Mobile App Development Made (Very) Easy' on Eclipse ADT need help HOT 1
- AndroidManifest "android:debuggable=true" in the exported one.
- External config of Android SDK version
- draw() affecting onBackPressed() HOT 8
- Unable to locate javac HOT 10
- Processing 2.1.1 error 542: Unable to resolve project target HOT 1
- Some classes from my library can't be found on android HOT 1
- Arc displayed transparent
- Creating a custom renderer HOT 2
- Fatal error while starting 3D sketch on Android device HOT 1
- Exception thrown in Android mode on right-click->Find in Reference HOT 4
- Unable to run on device; stuck compiling HOT 3
- Making a new PGraphics and displaying causes NullPointer HOT 1
- Android mode doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from processing-android-archive.