Author: duncan
Date: Mon Dec 11 19:22:05 2006
New Revision: 8719

Modified:
   branches/rel-1/freevo/src/util/videothumb.py

Log:
Corrected generation of video thumbnail for pygame


Modified: branches/rel-1/freevo/src/util/videothumb.py
==============================================================================
--- branches/rel-1/freevo/src/util/videothumb.py        (original)
+++ branches/rel-1/freevo/src/util/videothumb.py        Mon Dec 11 19:22:05 2006
@@ -82,12 +82,12 @@
                 image.thumbnail((255,255))
 
             if image.mode == 'P':
-                image = image.convert('RGB')
+                image.mode = 'RGB'
 
             if image.width * 3 > image.height * 4:
                 # fix image with blank bars to be 4:3
                 nh = (image.width*3)/4
-                ni = Image.new((image.width, nh))
+                ni = Image.new((image.width, nh), from_format = image.mode)
                 ni.draw_rectangle((0,0), (image.width, nh), (0,0,0,255), True)
                 ni.blend(image, dst_pos=(0,(nh- image.height) / 2))
                 image = ni
@@ -98,11 +98,14 @@
 
             # crop some pixels, looks better that way
             image = image.crop((4, 3), (image.width-8, image.height-6))
+            # Pygame can't handle BGRA images
+            if image.mode == 'BGRA':
+                image.mode = 'RGBA'
             if imagefile.endswith('.raw.tmp'):
                 f = vfs.open(imagefile[:-4], 'w')
-                #f.write('FRI%s%s%5s' % (chr(image.width), chr(image.height), 
image.mode))
-                f.write('FRI%s%s%5s' % (chr(image.width), chr(image.height), 
'RGB'))
-                f.write(str(image.get_raw_data(format='RGB')))
+                data = (str(image.get_raw_data(format=image.mode)), 
image.size, image.mode)
+                f.write('FRI%s%s%5s' % (chr(image.width), chr(image.height), 
image.mode))
+                f.write(data[0])
                 f.close()
                 os.unlink(imagefile)
             else:

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to