I've modified PIL to load palette files in .act format (the one that
pthotoshop export) here i attached the diff with ImagePalette.py and
ActPaletteFile.py (the one that deals with loading .act files).
Hope this help someone.

--
LuCaS
----------------------------------------------------
Open Your Mind, Use Open Source

Attachment: ImagePalette.py.diff
Description: Binary data

#
# Python Imaging Library
# $Id: ActPaletteFile.py 2134 2007-12-03 16:51 gecko $
#
# stuff to read simple, .act-style palette files
#
# 
# Copyright (c) Shrewsbury Lucas 2007.
#
# See the README file for information on usage and redistribution.
#

import string
from struct import *

##
# File handler for .act-style palette files.

class ActPaletteFile:
	rawmode = "RGB"

	def __init__(self, fp):

		self.palette = []

		if self.rawmode	== "RGB":
			self.read_length = 3

		pack = ''
		for i in range(self.read_length):
			pack = pack + 'c'

		itemList = []
		for i in range(256):

			s = fp.read(self.read_length)

			if not s:
				break
			if len(s) != self.read_length:
				raise SyntaxError, "bad palette file"

			upack = unpack(pack, s)

			for item in upack:
				itemList.append(ord(item))
		self.palette = itemList

	def getpalette(self):
		return self.palette, self.rawmode

_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to