Compress the byte array in Java and decompress it in C

I currently have the following arrays in my java program,

byte[] data = new byte[800];

I want to compress it before sending it to the microcontroller through the serial port (115200 baud) I want to decompress the array with a microcontroller in C But I'm not sure what the best way is Performance is a problem because the microcontroller is just an Arduino, so it can't be too memory / CPU intensive The data is more or less random (edit, I guess it's not so random, see the edit below) I would say because it represents the RGB color value of every 16 bits

What is the best way to compress this data? Know how much compression I can get?

edit

Sorry for the lack of information I need to compress lossless. I'm only going to send 800 bytes at a time My problem is that 800 bytes can't be transmitted quickly at the 115200 baud rate I'm using I wish I could reduce my size a little to improve my speed

Every two bytes looks like:

0RRRRRGGGGGBBBBB

The R, G and b bits represent the values of red, green and blue color channels respectively Then, every two bytes is 20 × 20 single LED on grid I would imagine that many two bytes are the same, because I often assign the same color code to multiple LEDs It is also possible that the RGB value is usually > 1 Because I usually use bright colors (however, this may be a pointless point because they are usually not > 15 at a time)

Solution

If the data is "more or less random", then compressing it won't have much luck, I'm worried

UPDATE

In view of the new information, I bet you don't need 32K color on your LED display I imagine a 1024 or 256 color palette may be enough Therefore, you can use a simple compression scheme (simply map each word through a lookup table, or maybe just discard the LSBs of each component), which can even be used for completely irrelevant pixel values

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>