473,785 Members | 2,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Doing bitmap things without python imaging library (PIL)

kudos
127 Recognized Expert New Member
First, PIL is a great library, however, sometimes I do perhaps not work on my own computer, but rather some obscure computer with an old version of python, with an unknown unix/linux that I have to telnet to. However, I still might want to create some images for instance for no particular reason make a display hack

Below is a packed together routine, that creates an TGA image from an pixmap (i.e. a list that defines a bitmap) with an example how-to use

Expand|Select|Wrap|Line Numbers
  1. def writetga(width,height,data,filename):
  2.  f = open(filename,"wb")
  3.  f.write("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c" % (0,0,2,0,0,0,0,0,0,0,0,0,(width & 0x00ff)%0xff,(width & 0xff00)%0xff,(height & 0x00ff)%0xff,(height & 0xff00)%0xff,0x18,0x0))
  4.  for i in range(height-1):
  5.   for j in range(width-1):
  6.    f.write("%c%c%c" % (data[j+i*(width-1)][0],data[j+i*(width-1)][1],data[j+i*(width-1)][2]))
  7.  f.close()
  8.  
  9. pixmap = []
  10. for i in range(256):
  11.  for j in range(256):
  12.   pixmap.append([(i^j)%256,(i^j)%256,(i^j)%256])
  13.  
  14. writetga(256,256,pixmap,"test1.tga")
  15.  
-kudos
Aug 11 '09 #1
0 5993

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2596
by: Jeremy Bowers | last post by:
I have an image in the Python Image Library. I'm trying to get it into PyGTK in color. Is there any way to do this cross-platform, preferably without writing to anything to the disk? PIL apparently can't write XPMs. GTK will only take XPMs, that I can see. Therein lies the rub. I can ship over monochrome bitmaps via XBM, but I'd rather be able to ship over full color. (Use case, in case it matters: I am trying to embed a graphic into a...
2
4112
by: peter.mosley | last post by:
A few weeks ago I asked for advice about which GUI toolkit I should learn, and receved several helpful answers. In the end I went with Tkinter. This was because a) it was already installed on the machines I am most likley to use, b) it is cross platform, and c) it was not as complex as PyGtk - which I tried and was totally unable to decipher. I am now at the point of trying to import the Python Imaging Library, and I have reached a...
1
5822
by: Stuart | last post by:
I am using the Python Imaging Library (PIL) to process GIF images. I need to be able to retrieve the RGB values for each color palette entry. I see that the 'Image' class has a 'palette' attribute which returns an object of type 'ImagePalette'. However, the documentation is a bit lacking regarding how to maniuplate the ImagePalette class to retrieve the palette entries' RGB values. Can anyone point me to a short example? Thanks!
0
1226
by: amaltasb | last post by:
Hi, I am hosting python applicaitions on a shared hositng so I dont have enough privilages, I have installed python in my home folder, through Automatic installer > extratools.php I want to install Python imaging library module. I just copied the PIL in my py24 folder and also in site packages, but its not working. How can I install PIL using extratools.php
2
1876
by: Tim Adler | last post by:
Hey everybody, I'm quite new to Python. I'm working on a webproject with Django and need to install the Python Imaging Library. It worked fine under Mac OS but when I try it on my Linux server. It gives me this error: PasteBin Link: http://phpfi.com/179314 I don't really know what is wrong. Can somebody point me directions. I really need the PIL to work.
2
2740
by: moishyyehuda | last post by:
can I download Python Imaging Library (PIL) for linux.
0
1085
by: moishyyehuda | last post by:
Hi I uploaded a pil library to my server. The problem is that I can't access the server with a command line. You see in order for the library to work you need to run setup.py and supply commands to the server when the setup.py script runs. so is there a solution to this. can I get a predone pil library (a pil library that I wont have the ru setup.py, and supply commands). Thanks in advance
2
1668
by: Sid | last post by:
Hi, I am tryin to copy an image into my own data structure(a sort of 2d array for further FFT). I've banged my head over the code for a couple of hours now. The simplified version of my problem is below. #-----------------Code------------------------ import Image pic = Image.open("Images/a.jpg")
1
1187
by: Marek Kralewski | last post by:
Hi, I am writing a script to convert EPS to PNG images. I need to set the resolution (and geometry accordingly), since the rendered images are to small. The resolution and geometry must be given as switches to the gs command. Is there a way to overload the Ghostcript function in the EpsImagePlugin.py file or to overload the plugin or to write a custom plugin without interfering with the PIL? The question hopefully seems trivial to a...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10148
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10091
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3646
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.