use of processing.core.PImage in project hid-serial by rayshobby.
the class GCScheme method makeColorSchemes.
/**
* Called every time we create a control. The palettes will be made when
* the first control is created.
*
* @param app
*/
public static void makeColorSchemes(PApplet app) {
// otherwise do nothing
if (palettes != null)
return;
// Load the image
PImage image = null;
;
InputStream is = app.createInput("user_gui_palette.png");
if (is != null) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
image = app.loadImage("user_gui_palette.png");
GMessenger.message(USER_COL_SCHEME, null);
} else {
// User image not provided
image = app.loadImage("default_gui_palette.png");
}
// Now make the palletes
palettes = new int[16][16];
jpalettes = new Color[16][16];
for (int p = 0; p < 16; p++) for (int c = 0; c < 16; c++) {
int col = image.get(c * 16 + 8, p * 16 + 8);
palettes[p][c] = col;
jpalettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
}
}
use of processing.core.PImage in project joons-renderer by joonhyublee.
the class JRImagePanel method getInversedImage.
public PImage getInversedImage() {
int iw = Math.round(w);
int ih = Math.round(h);
PImage inversed = new PImage(iw, ih);
for (int i = 0; i < ih; i++) {
for (int j = 0; j < iw; j++) {
//PApplet.println(i);
//PApplet.println(j);
inversed.pixels[(ih - i - 1) * iw + j] = image.getRGB(j, i);
;
}
}
return inversed;
}
use of processing.core.PImage in project hid-serial by rayshobby.
the class GCScheme method makeColorSchemes.
/**
* This method is called by the G4P GUI Builder tool when there is no
* sketch = no PApplet object to use
*/
public static void makeColorSchemes() {
// otherwise do nothing
if (palettes != null)
return;
// Load the image
PImage image = new PImage((new javax.swing.ImageIcon(new GCScheme().getClass().getResource("/data/default_gui_palette.png"))).getImage());
// Now make the palletes
palettes = new int[16][16];
jpalettes = new Color[16][16];
for (int p = 0; p < 16; p++) for (int c = 0; c < 16; c++) {
int col = image.get(c * 16 + 8, p * 16 + 8);
palettes[p][c] = col;
jpalettes[p][c] = new Color((col >> 16) & 0xff, (col >> 8) & 0xff, col & 0xff);
}
}
use of processing.core.PImage in project hid-serial by rayshobby.
the class GCustomSlider method loadStyle_FromSketch.
/**
* Load a skin when run as an application or run locally.
*
* @param styleFolder
* @param style
* @return true if the style loaded successfully
*/
private boolean loadStyle_FromSketch(String style) {
// First attempt to locate the style inside the sketch or sketch data folders
File styleFolder = new File(winApp.dataPath(style));
if (!styleFolder.exists())
styleFolder = new File(winApp.sketchPath(style));
// and if successful we are done
if (!styleFolder.exists())
return false;
int fcount = 0;
String[] names = new String[] { "centre.", "end_left.", "end_right.", "handle.", "handle_mouseover." };
PImage[] images = new PImage[names.length];
File[] fileList = styleFolder.listFiles();
for (int i = 0; i < names.length; i++) {
for (File f : fileList) {
String filename = f.getName();
if (filename.startsWith(names[i])) {
images[i] = winApp.loadImage(style + "/" + filename);
fcount++;
}
}
}
if (fcount != names.length)
return false;
centre = images[0];
leftEnd = images[1];
rightEnd = images[2];
thumb = images[3];
thumb_mouseover = images[4];
return true;
}
use of processing.core.PImage in project hid-serial by rayshobby.
the class GTextIconAlignBase method setIcon.
/**
* Set the icon to be used and the horizontal and/or vertical icon alignment.
* Use the constants in GAlign e.g. <pre>GAlign.LEFT</pre> <br>
*
* @param fname the filename of the icon
* @param nbrImages number of tiled images in the icon
* @param horz LEFT or RIGHT
* @param vert TOP, MIDDLE, BOTTOM
*/
public void setIcon(String fname, int nbrImages, GAlign horz, GAlign vert) {
PImage iconImage = ImageManager.loadImage(winApp, fname);
setIcon(iconImage, nbrImages, horz, vert);
}
Aggregations