Skip to content

NullPointerException when background exceeds color range when writing PDF #740

@processing-bot

Description

@processing-bot

Created by: clankill3r

Processing 4.2
OSX 10.15.7

When using a background value highter then the color range when recording a pdf, a NullPointerException is thrown:

import processing.pdf.PGraphicsPDF;

void settings() {
  size(1024, 768);
}

public void setup() {
  beginRecord(PDF, "output/cover.pdf");
  colorMode(RGB, 1);
  background(255);
  endRecord();
}

It happens in PGraphicsJava2D on the last line shown here:

  // BACKGROUND


  int[] clearPixels;

  protected void clearPixels(int color) {
    // On a hi-res display, image may be larger than width/height
    int imageWidth = image.getWidth(null);

In some way, it might not be a bug but a mistake by the user for exceeding the range, but yet I feel like it might be a bug as well...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions