PImage.resize() giving error on android

edited July 2014 in Android Mode

Hi! I am making my final year android project for which i need to deal with many images. The problem i am facing is that when i try to resize the images, using PImage.resize() function, it gives some "......checkPixelsAccess(..)", "......setPixels(.....)" errors. What should i do to resize my images. I want to resize the images so that they fit in any device. here is the code which is giving error:

class Menu {
      PImage mainback, infoback, board;
      PImage playButton, aboutButton, infoButton, scoreButton, exitButton;
      PImage backButton, gdandaButton, koklaButton, pittuButton, stapuButton, oonchButton;
      PImage left, right;
      Stack menus;  
      Menu() {
        mainback = loadImage("main_back.jpg");
        infoback = loadImage("info_back.jpg");
        board = loadImage("board.png");
        playButton = loadImage("b1.png");
        aboutButton = loadImage("b2.png");
        infoButton = loadImage("b3.png");
        scoreButton = loadImage("b4.png");
        exitButton = loadImage("b5.png");
        gdandaButton = loadImage("b6.png");
        koklaButton = loadImage("b7.png");
        pittuButton = loadImage("b8.png");
        stapuButton = loadImage("b9.png");
        oonchButton = loadImage("b10.png");
        left = loadImage("left.png");
        right = loadImage("right.png");
        backButton = loadImage("back.png");
        menus = new Stack();
        menus.push("main"); 
      }

      public void createButtons(int w, int h) {  // for the creation of all buttons in the game
        playButton.resize(0, h/10);
        PImage []play = {
          playButton, playButton, playButton
        };
        cp5.addButton("play")
          .setValue(1)
            .setPosition(w/2-playButton.width/2, h/8)
              .setImages(play)
                .setSize(playButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        aboutButton.resize(0, h/10);
        PImage []about = {
          aboutButton, aboutButton, aboutButton
        };
        cp5.addButton("about")
          .setValue(2)
            .setPosition(w/2-aboutButton.width/2, 2*h/8)
              .setImages(about)
                .setSize(aboutButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        infoButton.resize(0, h/10);
        PImage []info = {
          infoButton, infoButton, infoButton
        };
        cp5.addButton("info")
          .setValue(3)
            .setPosition(w/2-infoButton.width/2, 3*h/8)
              .setImages(info)
                .setSize(infoButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        scoreButton.resize(0, h/10);
        PImage []score = {
          scoreButton, scoreButton, scoreButton
        };
        cp5.addButton("score")
          .setValue(4)
            .setPosition(w/2-scoreButton.width/2, 4*h/8)
              .setImages(score)
                .setSize(scoreButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        exitButton.resize(0, h/10);
        PImage []exit = {
          exitButton, exitButton, exitButton
        };
        cp5.addButton("exit")
          .setValue(5)
            .setPosition(w/2-exitButton.width/2, 5*h/8)
              .setImages(exit)
                .setSize(exitButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        gdandaButton.resize(0, h/10);
        PImage []gdanda = {
          gdandaButton, gdandaButton, gdandaButton
        };
        cp5.addButton("gdandainfo")
          .setValue(6)
            .setPosition(w/2-gdandaButton.width/2, h/8)
              .setImages(gdanda)
                .setSize(gdandaButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        koklaButton.resize(0, h/10);
        PImage []kokla = {
          koklaButton, koklaButton, koklaButton
        };
        cp5.addButton("koklainfo")
          .setValue(7)
            .setPosition(w/2-koklaButton.width/2, 2*h/8)
              .setImages(kokla)
                .setSize(koklaButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        pittuButton.resize(0, h/10);
        PImage []pittu = {
          pittuButton, pittuButton, pittuButton
        };
        cp5.addButton("pittuinfo")
          .setValue(8)
            .setPosition(w/2-pittuButton.width/2, 3*h/8)
              .setImages(pittu)
                .setSize(pittuButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        stapuButton.resize(0, h/10);
        PImage []stapu = {
          stapuButton, stapuButton, stapuButton
        };
        cp5.addButton("stapuinfo")
          .setValue(9)
            .setPosition(w/2-stapuButton.width/2, 4*h/8)
              .setImages(stapu)
                .setSize(stapuButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        oonchButton.resize(0, h/10);
        PImage []oonch = {
          oonchButton, oonchButton, oonchButton
        };
        cp5.addButton("oonchinfo")
          .setValue(10)
            .setPosition(w/2-oonchButton.width/2, 5*h/8)
              .setImages(oonch)
                .setSize(oonchButton)
                  .updateSize()
                    .setVisible(false)
                      ;
        left.resize(w/25, h/15);
        PImage []left1 = {
          left, left, left
        };
        cp5.addButton("left")
          .setValue(11)
            .setPosition(w/20-left.width/2, h/2)
              .setImages(left1)
                .setSize(left)
                  .updateSize()
                    .setVisible(false)
                      ;
        right.resize(w/25, h/15);
        PImage []right1 = {
          right, right, right
        };
        cp5.addButton("right")
          .setValue(12)
            .setPosition(w-w/20-right.width/2, h/2)
              .setImages(right1)
                .setSize(right)
                  .updateSize()
                    .setVisible(false)
                      ;
        backButton.resize(w/25, h/15);
        PImage []back = {
          backButton, backButton, backButton
        };
        cp5.addButton("back")
          .setValue(13)
            .setPosition(w/80, h/50)
              .setImages(back)
                .setSize(backButton)
                  .updateSize()
                    .setVisible(false)
                      ;
      }
 }

I will be very thankful to you guys if you can help me.

Answers

Sign In or Register to comment.