Sorry, I was using an analogy.
Code and test images hereThe applet code is below. Only the bline function is ommitted and all that does is return the amount of pixels not of a color on a line.
Code:
import processing.pdf.*;
boolean operationComplete = false; //Finished drawing?
boolean savedFile = false; //Saved file?
boolean pixel = false; //Draw pixel rectangles?
boolean lines = true; //Draw lines?
boolean quadDraw = false; //Draw only in 4 directions?
PImage scan; //Image to scan
int col; //Current colour
int i = 0; //Iteration
int magnify = 20; //Scaling
int getRow = -1; //Row counter
void setup(){
//Run once then rectify actual scan dimensions
size(212 * magnify, 160 * magnify, PDF, "vector.pdf");
//change to appropriate file
scan = loadImage("logoc.gif");
println("wide:" + scan.width + " high:" + scan.height);
background(255);
rectMode(CENTER);
scan.loadPixels();
noFill();
}
void draw(){
if(!operationComplete){
col = scan.pixels[i];
if(col != #FFFFFF){
if(lines){
for(int j = 0; j < scan.pixels.length; j++){
int xj = j % scan.width;
int yj = j / scan.width;
int xi = i % scan.width;
int yi = i / scan.width;
if(i != j && xj >= xi && !(xj == xi && yj < yi) && !(quadDraw && (xj != xi && yj != yi && (abs(xj - xi) != abs(yj - yi))))){
if(bline(i % scan.width, i / scan.width, j % scan.width, j / scan.width, col, scan) == 0){
stroke(col);
line((i % scan.width)*magnify, (i / scan.width)*magnify, (j % scan.width)*magnify, (j / scan.width)*magnify);
}
else{
stroke(0);
}
}
}
}
if(pixel){
fill(col);
rect((i % scan.width)*magnify, (i / scan.width)*magnify, magnify, magnify);
}
}
if (i == scan.pixels.length - 1){
operationComplete = true;
}
else{
i++;
int yi = i / scan.width;
if(yi > getRow){
getRow = yi;
println("Scanning row:" + getRow + " of " + scan.height);
}
}
if(operationComplete && !savedFile){
exit();
savedFile = true;
println("all done");
}
}
}
It generally breaks with an image larger than depicted in the code. My thought was that this is normal. The only weird thing about it is that the power of the computer is irrelevant, at a certain size it breaks.