PImage color format

edited April 2014 in How To...


I'm current sending live footage from a HD camera to processing. The image formats between processing and the c++ program are different. So the image/video that I'm sending is current in a RGBA image format (also can supports BGRA), so as I know in processing/Java only supports ARGB color format and RGB.

Here is the reading image code in processing.

        public PImage GetImage() {
            PImage img = parent.createImage(WIDTH, HEIGHT, parent.ARGB);
            PApplet.arrayCopy(Nui_GetImage(), img.pixels);
            return img;

Is there a way to make a fast the conversion between RGBA to ARGB because the incoming video is in 1080p, or there is another Image library that supports RGBA format in processing or java.




  • edited May 2015 Answer ✓

    Perhaps something like this? %%-

     * RGBa_&_BGRa_To_aRGB (v1.04)
     * by GoToLoop (2014/Apr)
     * forum.processing.org/two/discussion/4461/pimage-color-format
    static final color RGBa_To_aRGB(final color c) {
      return c<<030 | c>>>010;
    static final color BGRa_To_aRGB(final color c) {
      final color a = c<<030;
      final color b = c>>>030;
      final color r = c<<010 & PImage.RED_MASK;
      final color g = c>>010 & PImage.GREEN_MASK;
      return a|r|g|b;
    void setup() {
Sign In or Register to comment.