/* tv_img2font - image to font data converter. Copyright (C) 2010 Yana Artishcheva tv_img2font is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. tv_img2font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AdVegam Server; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA E-mail: yana_artis @ advegam . com (remove "anti-spam" spaces) */ PImage img; // Declare variable "a" of type PImage int CHAR_W = 8; int CHAR_H = 9; int IMG_W = 128; int IMG_H = 144; void setup() { size(IMG_W, IMG_H); img = loadImage("fnt_press-start-k_8x9_koi.png"); noLoop(); // Makes draw() only run once } void draw() { // Displays the image at its actual size at point (0,0) image(img, 0, 0); int x, y, n, counter = 0, c; int row, col; for (y = 0; y < CHAR_H; y++) { for (row = 0; row < IMG_H; row += CHAR_H) { for (col = 0; col < IMG_W; col += CHAR_W) { n = 0; for (x = 0; x < CHAR_W; x++) { if (img.get(col+x, row+y) == -1) { c = 0; } else { c = 1; } n = (n << 1) | c; } if (counter > 0) { print(","); } print("0x"); print(hex(n, 2)); n = 0; if (((++counter) & 0x0F) == 0) { println(""); } } } } println("Done."); }