loadPixels() quick question
in
Programming Questions
•
1 years ago
I'm trying to get all my pixels, so I used loadPixels(), but the resulting pixels[] only contains the value -3355444.00.
- import Jama.util.*;
- import Jama.*;
- import Jama.test.*;
- import Jama.examples.*;
- import javax.swing.JOptionPane;
- PImage picture;
- void setup(){
- size(600, 600);
- String filename = getFilename();
- picture = loadImage(filename);
- size(picture.width, picture.height);
- loadPixels();
- double[][] pixel2DArray = new double[picture.height][picture.width];
- int index = 0;
- for (int i=0; i< picture.height; i++){
- for(int j=0; j< picture.width; j++){
- if(index < pixels.length){
- pixel2DArray[i][j] = pixels[index];
- index++;
- }
- }
- }
- Matrix pictureMatrix = new Matrix(pixel2DArray);
- pictureMatrix.print(10,2);
- }
- void draw(){
- image(picture, 0, 0);
- }
- String getFilename(){
- return JOptionPane.showInputDialog("What is the name of the file (include extension)?");
- }
1