Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Help with a programming problem

Name: Anonymous 2007-09-22 1:38 ID:b7ylIByJ

I've been trying to do this for ages now, and it seems like it should be something with a really simple and elegant solution, but i can't find it. 

The problem:  I have a series of images, all with the same dimensions.  I am using two templates in order to combine these images into 1 overall image.  The two templates are as such, one combines them horizontally, one vertically. As images are combined, they are scaled appropriately to fit the canvas, and a number of iterations of these templates can take place. Link is to visual example of this.

http://img230.imageshack.us/img230/4391/templateexamplewa6.jpg

I've managed to somewhat acheive this through image manipulation, but i need to do it via sheer maths (processing speed).  An added problem is that like in iteration 3, there are 3 images in the row. They should all be 33% of the canvas width each, and image 2 should be 66%. 

Any help would be greatly appreciated, it has made my head hurt.  It's also possible my explanation blows, so feel free to ask questions.

Name: Anonymous 2007-09-22 3:57 ID:1FrTAxla

Alright, here's the deal. Start with a canvas C containing an image. You will also have two variables W and H to keep track of how many times you've applied template 0 (increments W) and 1 (increments H). The pseudocode:

X <- 1
Y <- 1

C <- Canvas
W <- width of C
H <- height of C

function Template0(newImage):
    X <- X + 1
    copy C to tempImage
    scale tempImage width by (X-1)/X
    paste tempImage on C at (0,0)
    scale newImage width by 1/X
    paste newImage on C at (0,W-1/X)

Template1 is the same, just swap X for Y, H for W, etc.

I *think* that's what you wanted, anyway.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List