Want to encode some raw text byte/hex pattern/sequences with GH,Python or C#. Goal: 8bit Grayscale images.
kind of run length structure: 4 or 1 byte chunks but you have to extract chunksize inside every chunk.
So does anybody have fast code to compare every first byte pair of a chunk, read the bytes (4 or one)
and then get the startindex/offset of the next chunk. iterate and maybe draw the decompressed pixels. chatgpt?
Sorry, want to DECODE the text files.
I can’t understand the rule for the decoding from this diagram. Step by step, how does the reasoning work? In particular, what is the rule that tells us, whether we have a 1-byte or a 4-byte chunk? When it is a 1-byte chunk, do we just output that value directly, or just what? And then - where exactly are you stuck? Do you know how to read from a file? If you have the output values, do you know how to create an image file? Why is it important for the code to be fast? (For example, did you already write something that is too slow?)
Also: how will you decide the width of the output image?
Rule: read the first and second byte, compare them, if equal then its a 4 byte chunk. If they are not equal take the first value directly (1byte chunk).
I have written something inside Rhino3d/Grasshopper3d. i have read/convered the text with Python and iterate with a small plugin (Hoopsnake/ Loop) — too slow.
The example files are fragments of larger textfiles containing 2d/3dcoordinates/surfaces creases/colors/jpg-images and these encoded grayscale Alpha Channels. The width/height informations are readable inside this file.
Stuck: dont know nothin how to struct/partiton/indexing-chunks in python. (itertools?memview?buffer?yield?partial or complete file)
Ah, so then the reason for adding 2 is that the next two bytes in a 4-byte chunk are a repetition count, and a single byte value would be used for a single repetition. So we win when there is a long repeated run, lose for exactly two or three consecutive appearances of a value, and otherwise don’t change anything. Ok.
What exactly does this mean? What “text” are you reading and converting, and how exactly is the file represented? (I.e.: if you try to open the file with a text editor, do you see a hex dump, some incomprehensible garbage, or just what?) What are Hoopsnake and Loop; how are you making a “plugin” with them; and why is that helpful for “iterating” (as opposed to just writing a normal loop in Python code)? What actual overall code do you have? How much time does it take, and how far is that from your requirement?