We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi.
I have trying to do my own image enlargement method in Processing,but i´m stuck at the moment.I keep getting "Nullpointexeption" error message.I need to take copy of the original image and scale that with nearest neighbour.The other image needs to be scaled with bilinear.After that,these two images have to blended together depending of the RGB color difference between them.If difference is smaller than 128,bilinear is used.If greater, nearest neighbour is used.Here´s the code:
PImage img; // Declare variable "a" of type PImage
void setup() {
size(1200, 900);
// The image file must be in the data folder of the current sketch
// to load successfully
background(loadImage("example.jpg")); // Load the background image into the program
PImage img = loadImage("example - Copy.jpg"); // Load the foreground image into the program
}
void draw() {
// Displays the image at its actual size at point (0,0)
noSmooth();
image(img, 0, 0, 2400, 1800);
image(img, 0, 0);
blend(img, 0, 0, 2400, 1800, 0, 0, 2400, 1800, BLEND);
}
So how do i enlarge two images using different resizing methods?
Answers
In line 8 you have created a local variable called
img
this mask the global one in line 1 which remains null, hence NPE in the draw method.Change line 8 to
img = loadImage("example - Copy.jpg"); // Load the foreground image into the program