1. An image compression device comprising: a memory; and a processor configured to execute instructions stored in the memory and to: set a basic unit of compression by independently using each of a luminance (Y), a first chroma component (Cb), and a second chroma component (Cr) forming colors of a pixel of image data or by arbitrarily combining Y, Cb, and Cr forming colors of a pixel of image data; and generate compression data for an image and compress a value of the basic unit according to an encoding process based on a predetermined rule by sequentially executing on image data: a first encoding process for converting a value of a target pixel regarding the basic unit into difference information with a value of an immediately previous pixel, a second encoding process for, when a plurality of pixels having values equal to the value of the immediately previous pixel for the basic unit are continuous, converting the values of the plurality of pixels into repetition number of times information, a third encoding process for, when a combination of values of the basic unit corresponds to a combination previously set as a palette, converting the combination of the values of the basic unit into palette identification information, and generating compression data obtained by adding code information showing the utilized encoding process.