# Path: mcomix/image_tools.py
# def fit_in_rectangle(src, width, height, scale_up=False, rotation=0):
# def fit_2_in_rectangle(src1, src2, width, height, scale_up=False,
#   rotation1=0, rotation2=0):
# def add_border(pixbuf, thickness, colour=0x000000FF):
# def get_most_common_edge_colour(pixbufs, edge=2):
#     def round_color(color, steps=10):
#         def round(color_value):
#     def get_edge_pixbuf(pixbuf, side, edge):
# def pil_to_pixbuf(image):
# def pixbuf_to_pil(pixbuf):
# def load_pixbuf(path):
# def load_pixbuf_size(path, width, height):
# def load_pixbuf_data(imgdata):
# def enhance(pixbuf, brightness=1.0, contrast=1.0, saturation=1.0,
#   sharpness=1.0, autocontrast=False):
# def get_implied_rotation(pixbuf):
# def combine_pixbufs( pixbuf1, pixbuf2, are_in_manga_mode ):
# def is_image_file(path):
#         IS_RGBA = image.mode == 'RGBA'


import Image
import ImageDraw
import ImageOps
from mcomix import image_tools
            g_px = y <= g[x] and fill or 0
            b_px = y <= b[x] and fill or 0
            im_data.putpixel((x + 1, height - 5 - y), (r_px, g_px, b_px))
    # Draw the outlines
    for x in xrange(1, 256):
        for y in range(r[x-1] + 1, r[x] + 1) + [r[x]] * (r[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (255, g_px, b_px))
        for y in range(r[x] + 1, r[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (255, g_px, b_px))
        for y in range(g[x-1] + 1, g[x] + 1) + [g[x]] * (g[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (r_px, 255, b_px))
        for y in range(g[x] + 1, g[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (r_px, 255, b_px))
        for y in range(b[x-1] + 1, b[x] + 1) + [b[x]] * (b[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (r_px, g_px, 255))
        for y in range(b[x] + 1, b[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (r_px, g_px, 255))
    if text:
        maxstr = 'max: ' + str(maximum)
        draw = ImageDraw.Draw(im)
        draw.rectangle((0, 0, len(maxstr) * 6 + 2, 10), fill=(30, 30, 30))
        draw.text((2, 0), maxstr, fill=(255, 255, 255))
    im = ImageOps.expand(im, 1, (80, 80, 80))
    im = ImageOps.expand(im, 1, (0, 0, 0))

# Path: mcomix/image_tools.py
# def fit_in_rectangle(src, width, height, scale_up=False, rotation=0):
# def fit_2_in_rectangle(src1, src2, width, height, scale_up=False,
#   rotation1=0, rotation2=0):
# def add_border(pixbuf, thickness, colour=0x000000FF):
# def get_most_common_edge_colour(pixbufs, edge=2):
#     def round_color(color, steps=10):
#         def round(color_value):
#     def get_edge_pixbuf(pixbuf, side, edge):
# def pil_to_pixbuf(image):
# def pixbuf_to_pil(pixbuf):
# def load_pixbuf(path):
# def load_pixbuf_size(path, width, height):
# def load_pixbuf_data(imgdata):
# def enhance(pixbuf, brightness=1.0, contrast=1.0, saturation=1.0,
#   sharpness=1.0, autocontrast=False):
# def get_implied_rotation(pixbuf):
# def combine_pixbufs( pixbuf1, pixbuf2, are_in_manga_mode ):
# def is_image_file(path):
#         IS_RGBA = image.mode == 'RGBA'


# Path: mcomix/histogram.py
import Image
import ImageDraw
import ImageOps
from mcomix import image_tools

            g_px = y <= g[x] and fill or 0
            b_px = y <= b[x] and fill or 0
            im_data.putpixel((x + 1, height - 5 - y), (r_px, g_px, b_px))
    # Draw the outlines
    for x in xrange(1, 256):
        for y in range(r[x-1] + 1, r[x] + 1) + [r[x]] * (r[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (255, g_px, b_px))
        for y in range(r[x] + 1, r[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (255, g_px, b_px))
        for y in range(g[x-1] + 1, g[x] + 1) + [g[x]] * (g[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (r_px, 255, b_px))
        for y in range(g[x] + 1, g[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (r_px, 255, b_px))
        for y in range(b[x-1] + 1, b[x] + 1) + [b[x]] * (b[x] != 0):
            r_px, g_px, b_px = im_data.getpixel((x + 1, height - 5 - y))
            im_data.putpixel((x + 1, height - 5 - y), (r_px, g_px, 255))
        for y in range(b[x] + 1, b[x-1] + 1):
            r_px, g_px, b_px = im_data.getpixel((x, height - 5 - y))
            im_data.putpixel((x, height - 5 - y), (r_px, g_px, 255))
    if text:
        maxstr = 'max: ' + str(maximum)
        draw = ImageDraw.Draw(im)
        draw.rectangle((0, 0, len(maxstr) * 6 + 2, 10), fill=(30, 30, 30))
        draw.text((2, 0), maxstr, fill=(255, 255, 255))
    im = ImageOps.expand(im, 1, (80, 80, 80))
    im = ImageOps.expand(im, 1, (0, 0, 0))

    return image_tools.pil_to_pixbuf(im)