#image #convert-images #png #jpeg #converter #c2p #c2b

classpad-image

A package to convert images to C2P and C2B files

1 unstable release

new 0.1.0 Mar 18, 2025

#365 in Images

MIT/Apache

29KB
382 lines

Introduction

The fx-CP400 calculator has the ability to display images within cerain programs. It can not use PNG or JPG files, it can, however, use the CASIO C2P format instead. There is also a second format, the C2B format, which is a animation file consisting of multiple images used in the 'Picture Plot' application. While there is offical software by CASIO available for converting images to C2P and C2B, these programs require a special password that is supposed to be given by your teacher. The C2P converter is based on this repository by the6p4c, the C2B converter was done entirely by myself. It only requires that you have Rust installed and a fx-CP400 calculator (with an USB cable).

How to use

  1. install Rust (if not already done)
  2. enter a folder of your choice, open your terminal and enter:
      git clone https://github.com/TAugustL/classpad-image.git
    
  3. Into C2P: enter the created folder, in your terminal enter:

      cargo run --example clt c2p [path/to/image.png] [target/path/image.c2p]"
    
  4. Into C2B: enter the created folder, in your terminal enter:

      cargo run --example clt c2b [path/to/image1.png] [path/to/image2.png] [path/to/image3.png] [target/path/image.c2b]"
    
  5. From C2P: enter the created folder, in your terminal enter:

      cargo run --example clt imgp [target/path/image.c2p] [path/to/image.png]"
    
  6. From C2B: enter the created folder, in your terminal enter:

      cargo run --example clt imgb [target/path/image.c2b] [path/to/image.png]"
    

Now you have your image as an C2P file. In the next steps you will need your calculator.

  1. plug your calculator with the USB cable to your PC
  2. in the window that should now open, press the first option (USB Flash)
  3. open the USB Drive that should now appear on your PC
  4. drag your C2P or C2B file in there
  5. securely remove your calculator from your PC

And done! Now you can open the image on your calculator!

How does it work?

There are some things in which C2P and C2B files are similar:
  • a valid size (max. 310 x 401), however if you use my program it will scale images that are too large down
  • a specific header (some bytes change depending on your file size!)
  • a zlib encryption for the image data (on default compression mode)
  • a specific footer (same in every C2P/C2B file)*
Here are the necessary bites for your file (mind the bytes that change in the header)

The C2B file format is a bit more complicated than the C2P format:

  • the file starts again with a header with files changing depending on your file size
  • following the header, there are four bytes containing the size of the following compressed picture
  • at the end of the compressed data, this repeats for each picture (header, 4 bytes, data, 4 bytes, data, ..., footer)
  • the file ends with a specific footer *this is the same for every C2B file, however, there are some bytes that have an effect on the environment inside the 'Picture Plot' application (some bytes change the window dimensions, no effect on picture itself)


If you have any tips for improvement or issues please open an issue!

Dependencies

~3.5MB
~63K SLoC