Python Forum
4 byte hex byte swap from binary file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
4 byte hex byte swap from binary file
#1
can't seem to find a solution that works.
the program I am working on basically takes a bunch of specially formatted texture files and dumps them into one large file with a special header (And subheaders)
issue I am running across seems really simply, but the solution is anything but.
I need to read a 4 byte location (easy enough)to get data size, SO I have to read that location then byte swap it .. IE read aa bb cc dd and turn it into dd cc bb aa so I can use the file size as an offset before the next texture. Everything I try seems to turn it into ascii equivalent and doesn't use the actual hex data. I don't understand why using the raw data is so difficult. I have done exhaustive searches, tried array.array, struct.pack/unpack while changing the endian..
anyone got an easy method?
Reply


Messages In This Thread
4 byte hex byte swap from binary file - by medievil - May-07-2018, 04:30 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Search for multiple unknown 3 (2) Byte combinations in a file. lastyle 7 1,257 Aug-14-2023, 02:28 AM
Last Post: deanhystad
  How do I read and write a binary file in Python? blackears 6 6,020 Jun-06-2023, 06:37 PM
Last Post: rajeshgk
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd2 in position 16: invalid cont Melcu54 3 4,704 Mar-26-2023, 12:12 PM
Last Post: Gribouillis
  extract only text strip byte array Pir8Radio 7 2,790 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
  sending byte in code? korenron 2 1,087 Oct-30-2022, 01:14 PM
Last Post: korenron
  UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 34: character Melcu54 7 18,315 Sep-26-2022, 10:09 AM
Last Post: Melcu54
  Byte Error when working with APIs Oshadha 2 980 Jul-05-2022, 05:23 AM
Last Post: deanhystad
  How to swap two numbers in fields in python Joni_Engr 5 1,804 Jan-11-2022, 09:43 AM
Last Post: menator01
  calculate data using 1 byte checksum korenron 2 2,878 Nov-23-2021, 07:17 AM
Last Post: korenron
  Hashing an address for binary file Python_help 8 2,567 Nov-04-2021, 06:23 AM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020