473,614 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OTA. to TGA extractor

kudos
127 Recognized Expert New Member
Do you remeber the OTA format? The simple graphic format that you could send as a SMS message? Anyway, I found a cool OTA image on my cellphone, and wanted to extract it to a "normal" graphics format, and add it to a t-shirt (it also writes the image out to stdout as a number of '#'s)

Expand|Select|Wrap|Line Numbers
  1. #ota2tga
  2.  
  3. def writetga(width,height,data,filename):
  4.  f = open(filename,"wb")
  5.  file = ""
  6.  file+="%c%c%c" % (0,0,2)
  7.  file+="%c%c%c%c%c" % (0,0,0,0,0)
  8.  file+="%c%c%c%c" % (0,0,0,0)
  9.  file+="%c%c" % ((width & 0x00ff)%0xff,(width & 0xff00)%0xff)
  10.  file+="%c%c" % ((height & 0x00ff)%0xff,(height & 0xff00)%0xff)
  11.  file+="%c%c" % (0x18,0x0)
  12.  for i in range(height):
  13.   for j in range(width):
  14.    file+="%c%c%c" % (data[j+(height-1-i)*(width-1)][0],data[j+(height-1-i)*(width-1)][1],data[j+(height-1-i)*(width-1)][2])
  15.  f.write(file)
  16.  f.close()
  17.  
  18. # add the name of your .ota file here.
  19. f = open("Grafikkmelding.ota","rb")
  20. info = ord(f.read(1))
  21. width = ord(f.read(1))
  22. height = ord(f.read(1))
  23. color = ord(f.read(1))
  24.  
  25. pixmap = [[255,255,255]]*(72*28)
  26. print width
  27. print height
  28. x = 0
  29. y = 0
  30. l = ""
  31. for i in range(height):
  32.  for j in range(width / 8):
  33.   v = ord(f.read(1))
  34.   for k in range(8):
  35.    if( ((v >> 7-k) & 0x01) == 0):
  36.     l+=" "
  37.     pixmap[x+y*width] = [255,255,255]
  38.    else:
  39.     l+="#"
  40.     pixmap[x+y*width] = [0,0,0]
  41.    x+=1
  42.    if(x > width):
  43.     x=0
  44.     y+=1
  45.  l+="\n"   
  46. f.close()
  47. print l
  48. writetga(width,height,pixmap,"output.tga")
  49.  
-kudos
Aug 15 '09 #1
0 3300

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

Similar topics

1
2404
by: Marco | last post by:
Hi, I am searching for a tool that extract information from a HTLM page and format it in xml format For instance for this page: http://money.guardian.co.uk/pensions/story/0,6453,993138,00.html get an xml file with a <title> with the title of the article
4
4569
by: cstudent79 | last post by:
Hello folks,how do u do ? I want to develop an application that can extract text from a powerpoint presentation.But i am in dark about the powerpoint file format.I would be obliged if somebody can help me with the file format. Thank u.
0
1302
by: bsimaie | last post by:
Hello group Since I want to modify a large program written in C(40K line) for the academic purposes and the program compose of several modules, it is necessary to have software structure in order to modify the program.Unfortunately the program has no documentation regarding software structure except comments inside code. Anybody knows what is the best tool for extracting structure of the large programs such as one I indicated above.?...
1
1778
by: _BNC | last post by:
I've been looking for a couple weeks for a regex expression that will extract text from html in a form that will look like IE screen output. I'm sure one of you guys hid it somewhere as a joke, but it's not funny any more. Give it up, OK? Seriously, I've checked regexlib.com and regular-expressions.info and lots of google searches. I find tag extractors and other related stuff but haven't come up with the 'visible text' extractor. ...
0
1586
by: Vijay | last post by:
h any know how the website extractor tool works thanks & regard Vijay
6
6853
by: isbat1 | last post by:
I need to extract some embedded resources back to disk from a .net assembly. What tool do I need, and where do I get it?
23
2506
by: Randy | last post by:
Since these operators can't be member functions, and since friend functions can't be declared virtual, how do I make my inserters and extractors polymorphic? --Randy Yates
0
8176
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8120
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
8620
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
8571
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
8265
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,...
1
6085
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
5537
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1705
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.