Beginner: HD (Bacon) Poster Creator

You read right, HD Customizable Bacon Posters free for all!!!!

BACON HD!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Alright, so this post is not only about bacon.

Is about using what we learned in the pointilism tutorial

and how can we use it to crete HD posters of any image we choose.

Let’s suppose you have this image

and you want to print a 120 inch poster to pimp your office wall.

If we take each pixel and turn it into a resizable circle

we can create a print any size we want, with any resolution we want.

If you love bacon enough or just want to create a poster

out of an low res pic you have, this is the right tutorial for you.

So, let’s get started;

copy, paste, read and run.


//You need this library to create the pdf.
//No need to download it’s already installed by default.
import processing.pdf.*;

PImage myImage;

float scaleTo;

void setup()
{
//Load your image.
myImage = loadImage(“bacon.jpg”);
//setWidth is a function that I created below.
//go check it out. It returns a float, handles decimals and shit.
//The parameters I send are setWidth(inches, pixels per inch, image width)
//The function will grab the width of the image
//and compare it to the desired width,
//then divides the desired/current and gets a number
//that can scale the image to get the desired width.
scaleTo = setWidth(72,100,myImage.width);
//Set the window to the size of the image.
size(int(scaleTo*myImage.width),int(scaleTo*myImage.height));

smooth();
//We’re only doing this once, no need to loop.
noLoop();

//Here you specify the name of your PDF.
beginRecord(PDF, “bacon72inWx100ppi.pdf”);
}

void draw()
{

//Let’s choose a dark background.
background(5);

//get the width and height of the image.
int iw = myImage.width;
int ih = myImage.height;
float fw,fh,ft;
fw = scaleTo*myImage.width;
fh = scaleTo*myImage.height;

int skl = int(scaleTo);

for (int i = 0; i < iw; i++){
for (int j = 0; j < ih; j++){
//Get the color of the pixel.
color pixelColor = myImage.get(i,j);
//Remove the stroke.
noStroke();
//Fill the ellipse with the pixel color.
fill(pixelColor);
//Draw the elipse.
ellipse(i*skl,j*skl,skl,skl);

ft = scaleTo*100*(j+i*fh)/(fw*fh);
println(“Percentage: “+int(ft)+”% completed.”);
}
}
//After this command the PDF is created,
//anything beyond it won’t be saved.
endRecord();
println(“Finished!”);
exit(); //we have to exit the window because is going to be fucking huuuuuge!
}

//This is the function I was talking about.
//As you can see it starts with float and not a void
//that means it’s going to return a value.
//when we use void is like calling your cousing
//and asking him to do math but keep the result to himself.
//with the float we can use a return, as you will see
//to return the value your cousin calculated.
float setWidth(float widthInches, int resolution, int imageWidth)
{
//As you can see we recieve the width in inches we want.
//the resolution in pixels
//and the image width
//first we calculate the desired width in pixels
float nw = widthInches*resolution;
//then we divide desired/current
float dif = nw/imageWidth;
//dif is the number to scale to the new image to have the desired size.
println(“Scale to: “+dif);
return dif;
}

This is how your pdf should look if you zoom in.

Download the 72 in pdf here:

bacon72inWx100ppi.pdf

Visit the reference:

http://www.processing.org/reference/

Read the other tutorials here:

Beginner: Download and Install Processing

Beginner: Pointilism or GTFO

Beginner: Adding a Library. Problem?

Beginner: Fucking Particles

Intermediate: Me Gusta Face Detection

Intermediate: Motherfucking Classes

Visit the blog where the bacon pic came from:

https://shotthefood.files.wordpress.com


Flattr this

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s