resizing an image captured by a phone-camera (ketai)

edited April 2014 in Android Mode

Hello,

I'm currently writing on a little Android-app in which I need to scale down the camera input to 8 by 6 pixels (original 320 x 240). I already found out I can do this using resize(). But there's one problem remaining: the pixels[] array of my resized image isn't recalculated but - it seems like it's the pixels of the orginal image, only truncated after 48 pixels. Here's my (simplified) 'draw-function:

void draw() { pImg = cam.get(); pImg.loadPixels(); pImg.updatePixels(); image(pImg, width/2, height/2, width, height); // write the original pixels to another array // for later comparision for(int i=0; i<48; i++) { origPx[i] = pImg.pixels[i]; } pImg.resize(8, 6); pImg.updatePixels(); for(int i=0; i<48; i++) { // compare the original pixels // with the ones from the scaled image // always prints 'true' println(pImg.pixels[i] == origPx[i]); } image(pImg, width/2, height/2, width, height); }

How can this be solved? Is it a bug in the Ketai lib? Am I doing something wrong?

Thanks very much for any hint

Stefan

Tagged:

Answers

  • Answer ✓

    Found the solution for my problem just 2 minutes after asking my question: instead of

    pImg.updatePixels()

    after resizing I am now using

    pImg.loadPixels

    ... and the result seems to be correct - made my day ;P

    Stefan

Sign In or Register to comment.