Skip to content

Commit

Permalink
Merge pull request #6 from ChainSwordCS/main
Browse files Browse the repository at this point in the history
Don't know exactly what I did but it works perfect
  • Loading branch information
Eiim authored Apr 29, 2021
2 parents c79509b + 5810066 commit 9810d6b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ https://cdn.discordapp.com/attachments/836413155894100050/837153929284157491/TGA

![](https://cdn.discordapp.com/attachments/836413155894100050/837153929284157491/TGAHZ.png)

## Commit []()

Fixed a bug in the byte-grabbing code which was causing weird errors at every RAW packet. This was the only bug remaining in the past two revisions.

Also, colors are pretty darn accurate.

https://cdn.discordapp.com/attachments/836413155894100050/837196767270666310/TGAHZ.png

![](https://cdn.discordapp.com/attachments/836413155894100050/837196767270666310/TGAHZ.png)

# Running the Script

Right now, the TGA image file and header information are hard-coded into the Python script.
Expand Down
40 changes: 1 addition & 39 deletions TGAHzParse.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def printrgb(rgb):

def torgb(b2, b1):

# Evolving based on how we interpret the format

# RRRRRGGG GGBBBBBA
r = int(b2/8)
g = (b2%8)*4 + int(b1/64)
Expand All @@ -28,26 +26,6 @@ def torgb(b2, b1):
ba = b*8+int(b/4)

return(r,g,b,ra,ga,ba)


def torgbspecial(b2, b1):

# Evolving based on how we interpret the format

r = int(b2/8)
g = (b2%8)*4 + int((b1%128)/32)
b = b1%32

# r = int((b1%128)/4)
# g = (b1%4)*8 + int(b2/32)
# b = b2%32

# Convert to 24-bit color (simple algorithm)
ra = r*8+int(r/4)
ga = g*8+int(g/4)
ba = b*8+int(b/4)

return(r,g,b,ra,ga,ba)

# Log each packet
log = True
Expand Down Expand Up @@ -104,23 +82,7 @@ def torgbspecial(b2, b1):
# Skip past two color bytes
i = i + 2
else:

# Use last pair first

# Two color bytes in LE order
b1 = data[i+packlen*2]
b2 = data[i+packlen*2+1]

if(log):
printrgb(format(b2, '08b')+" "+format(b1, '08b'))
if(image):
r,g,b,ra,ga,ba = torgbspecial(b2,b1)

imgdat.append(ra)
imgdat.append(ga)
imgdat.append(ba)

j = 1
j = 0
while(j < packlen):
# Two color bytes in LE order
b1 = data[i+j*2]
Expand Down

0 comments on commit 9810d6b

Please sign in to comment.