Jump to content

extract pixels returns black image


Fnapsi
 Share

Recommended Posts

Hi.

I have a newbie question. So I create a new PIXI application, draw a blue square onto it, wait a couple of seconds, and then manually start a function to extract the pixels. The extracted pixels are always black. If anybody could help me find out why this is the case, that would be great.

The blue square is correctly drawn and visible, and the extract function gives me a correct array of data, but all pixel information in it is black. As I execute the extract function right now manually, it's not possible that it's extracted too early or something like that.

Here are the important bits of the code:
 

initPixi() {
  let type = "WebGL";
  if(!PIXI.utils.isWebGLSupported()){
    type = "canvas";
  }

  this.pixi = new PIXI.Application({
        width: 0,
        height: 0,
        antialias: false,
        transparent: false,
        resolution: 1,
        autoResize: true,
        view: $('.imgCurrent')[0]
      }
  );
}

updatePixi() {
  this.pixi.renderer.resize(this.imgWidth, this.imgHeight);
  this.pixiDraw();
}

pixiDraw() {
  let rectangle = new PIXI.Graphics();
  rectangle.beginFill(0x66CCFF);
  rectangle.drawRect(0, 0, 200, 200);
  rectangle.endFill();
  rectangle.x = 0;
  rectangle.y = 0;
  this.pixi.stage.addChild(rectangle);
}

pixiExtract {
  this.pixi.renderer.extract.pixels();
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...