Author Topic: Badspot's Dev Server  (Read 15202 times)



Port, what the forget is with your avatar
How make it display different images for white/blueish background
Asdf

Port, what the forget is with your avatar
How make it display different images for white/blueish background
Asdf
Black magic.

You require fifty-seven pythons and two pieces of paper.

Black magic.

You require fifty-seven pythons and two pieces of paper.
No.


Black magic.

You require fifty-seven pythons and two pieces of paper.

only 51 pythons

Code: [Select]
# Import modules.
print 'Initializing.'
from math import floor
import Image

# Initialize images.
print 'Loading images.'
img1 = Image.open('img1.png')
img2 = Image.open('img2.png')

maxx = max(img1.size[0], img2.size[0])
maxy = max(img1.size[1], img2.size[1])
imgf = Image.new('RGBA', (maxx, maxy), (0, 0, 0, 0))

ima1 = img1.load()
ima2 = img2.load()
imaf = imgf.load()

# Subsitute color shape.
def replace_color(alp, mod):
    if type(alp) is tuple:
        if len(alp) == 4:
            alp = alp[3]
        else:
            alp = 255

    return ((255, 255, 255, alp), (175, 198, 219, alp))[mod]

# Perform operation.
print 'Performing operation.'
for i in range(maxx * maxy):
    y = floor(i / maxx)
    x = i - (y * maxx)
    
    try: a = ima1[x, y]
    except IndexError: a = (0, 0, 0, 0)

    try: b = ima2[x, y]
    except IndexError: b = (0, 0, 0, 0)

    if (x + y) % 2 == 0:
    # if True:
        # imaf[x, y] = a
        imaf[x, y] = replace_color(a, 0)
    else:
        # imaf[x, y] = b
        imaf[x, y] = replace_color(b, 1)

# Save output.
print 'Exporting.'
imgf.save('imgf.png')

essentially only 33 pythons because of comments and whitespace
« Last Edit: May 20, 2012, 12:18:07 PM by Port »

only 51 pythons

Code: [Select]
# Import modules.
print 'Initializing.'
from math import floor
import Image

# Initialize images.
print 'Loading images.'
img1 = Image.open('img1.png')
img2 = Image.open('img2.png')

maxx = max(img1.size[0], img2.size[0])
maxy = max(img1.size[1], img2.size[1])
imgf = Image.new('RGBA', (maxx, maxy), (0, 0, 0, 0))

ima1 = img1.load()
ima2 = img2.load()
imaf = imgf.load()

# Subsitute color shape.
def replace_color(alp, mod):
    if type(alp) is tuple:
        if len(alp) == 4:
            alp = alp[3]
        else:
            alp = 255

    return ((255, 255, 255, alp), (175, 198, 219, alp))[mod]

# Perform operation.
print 'Performing operation.'
for i in range(maxx * maxy):
    y = floor(i / maxx)
    x = i - (y * maxx)
   
    try: a = ima1[x, y]
    except IndexError: a = (0, 0, 0, 0)

    try: b = ima2[x, y]
    except IndexError: b = (0, 0, 0, 0)

    if (x + y) % 2 == 0:
    # if True:
        # imaf[x, y] = a
        imaf[x, y] = replace_color(a, 0)
    else:
        # imaf[x, y] = b
        imaf[x, y] = replace_color(b, 1)

# Save output.
print 'Exporting.'
imgf.save('imgf.png')
That has nothing to do with the image

That has nothing to do with the image

yes it does

place images named img1.png and img2.png in folder with that script
run script
suddenly, new image named imgf.png is in folder which displays those two depending on the background

yes it does

place images named img1.png and img2.png in folder with that script
run script
suddenly, new image named imgf.png is in folder which displays those two depending on the background
What file suffix?



Whatever python uses.

.py

requires this and this to run

Anyone else just open the forums hoping v21 is out than upset just to see that grey square on Developement.