postToWeb cannot save PNG
in
Contributed Library Questions
•
2 years ago
Hi,
I'm trying to use the postToWeb library to upload to a server an image I'm creating in my program. When I specify the selected file type through a
This is when I save it:
Looking at the code of the library it seems that PNG and GIF are treated the same and maybe the solution can lie in how I built the PGraphics (am I doing it right?)
I'm trying to use the postToWeb library to upload to a server an image I'm creating in my program. When I specify the selected file type through a
- setType()
- java.lang.IllegalArgumentException: im == null!
- at javax.imageio.ImageIO.write(ImageIO.java:1457)
- at javax.imageio.ImageIO.write(ImageIO.java:1571)
- at org.seltar.Bytes2Web.ImageToWeb.getBytes(ImageToWeb.java:142)
- at hackatar.keyPressed(hackatar.java:304)
- at processing.core.PApplet.handleKeyEvent(PApplet.java:1996)
- at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1979)
- at processing.core.PApplet.handleDraw(PApplet.java:1643)
- at processing.core.PApplet.run(PApplet.java:1530)
- at java.lang.Thread.run(Thread.java:680)
- <p><b>Error:</b> File is empty!</p>
This is when I save it:
- PImage img = get(0, controlOffset, width, wHeight); // I get a portion of the screen
- img.save(path +".png"); // I save it locally
- PGraphics pg = createGraphics(width, wHeight, P2D); // I create a PGraphics from it
- pg.loadPixels();
- img.loadPixels();
- for (int i = 0; i < img.pixels.length; i++)
- {
- pg.pixels[i] = img.pixels[i];
- }
- ImageToWeb imgTW = new ImageToWeb(this); //Creating imageToWeb
- imgTW.setType(ImageToWeb.PNG); //Setting Type
- imgTW.post("test", url, "hacktion", true, imgTW.getBytes(pg)); //posting to wesite
Looking at the code of the library it seems that PNG and GIF are treated the same and maybe the solution can lie in how I built the PGraphics (am I doing it right?)
1