Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- import pygame, sys, os
- from pygame.locals import *
- pygame.init()
- (windows_width, windows_height, windows_title) = (600, 400, "Image Loading")
- screen = pygame.display.set_mode((windows_width,windows_height),0,32)
- pygame.display.set_caption(windows_title)
- windows_bgcolor = (255,255,255)
- mainLoop = True
- clock = pygame.time.Clock()
- milli = seconds = 0.0
- #initial data here
- if pygame.image.get_extended():
- print 'My pygame the best'
- else:
- raise SystemExit, 'Sorry, extended image module required'
- image1 = pygame.image.load(os.path.join('images','img1.jpg'))
- image2 = pygame.image.load(os.path.join('images','img2.png'))
- image3 = pygame.image.load(os.path.join('images','img3.gif'))
- image4 = pygame.image.load(os.path.join('images','img4.bmp'))
- image5 = pygame.image.load(os.path.join('images','img5.pcx'))
- image6 = pygame.image.load(os.path.join('images','img6.tga'))
- image7 = pygame.image.load(os.path.join('images','img7.tif'))
- image8 = pygame.image.load(os.path.join('images','img8.png'))
- newSurf = pygame.Surface((windows_width, windows_height))
- newSurf.blit(image1, (0,0))
- newSurf.blit(image2, (128,0))
- newSurf.blit(image3, (256,0))
- newSurf.blit(image4, (384,0))
- newSurf.blit(image5, (0,128))
- newSurf.blit(image6, (128,128))
- newSurf.blit(image7, (256,128))
- newSurf.blit(image8, (384,128))
- pygame.image.save(newSurf,os.path.join('images','save_image_1.BMP'))
- print "save image_1"
- stringImage0 = pygame.image.tostring(image1, 'RGB')
- stringImage1 = pygame.image.tostring(image8, 'RGB')
- stringImage2 = pygame.image.tostring(image8, 'RGBA')
- stringImage3 = pygame.image.tostring(image6, 'RGB')
- #print stringImage
- newImage0 = pygame.image.fromstring(stringImage0, (128,128), 'RGB')
- newImage1 = pygame.image.fromstring(stringImage1, (128,128), 'RGB')
- newImage2 = pygame.image.fromstring(stringImage2, (128,128), 'RGBA')
- newImage3 = pygame.image.frombuffer(stringImage3, (128,128), 'RGB')
- newSurf.blit(newImage0, (0,256))
- newSurf.blit(newImage1, (128,256))
- newSurf.blit(newImage2, (256,256))
- newSurf.blit(newImage3, (384,256))
- pygame.image.save(newSurf,os.path.join('images','save_image_2.JPG'))
- print "save image_2"
- while mainLoop:
- for event in pygame.event.get():
- if event.type == QUIT:
- mainLoop = False
- screen.fill(windows_bgcolor)
- milli = clock.tick(40)
- seconds = milli / 1000.0
- #create frame here
- screen.blit(newSurf, (0,0))
- pygame.display.update()
- pygame.image.save(screen,os.path.join('images','img0.BMP'))
- pygame.quit()
- #destroy data here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement