Changeset 4708


Ignore:
Timestamp:
Nov 8, 2010 8:26:33 PM (5 years ago)
Author:
alxf
Message:
  • Convert RGB image to RGBA.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/python/examples/img2txt.py

    r4706 r4708  
    2929GMASK = 0x0000ff00
    3030BMASK = 0x000000ff
    31 AMASK = 0x00000000
     31AMASK = 0xff000000
    3232BPP = 32
    3333DEPTH = 4
     
    190190    #init dither
    191191    try:
     192        #convert rgb to rgba
     193        if img.mode == 'RGB':
     194            img = img.convert('RGBA')
     195        #reorder rgba
     196        if img.mode == 'RGBA':
     197            r, g, b, a = img.split()
     198            img = Image.merge("RGBA", (b, g, r, a))
     199
    192200        dit = Dither(BPP, img.size[0], img.size[1], DEPTH * img.size[0],
    193                       RMASK, GMASK, BMASK, AMASK)
     201                        RMASK, GMASK, BMASK, AMASK)
    194202    except DitherError, err:
    195203        sys.stderr.write("%s\n" % err)
Note: See TracChangeset for help on using the changeset viewer.