This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DK-TM4C129X: image.pnm file is not support more than 256 color

Part Number: DK-TM4C129X

hello 
        
        i am using ccs software to program dk-tm4c129x to upload image in display .and i am uisng  gimp software to convert pnm to c (software define in your data sheet SW-TM4C-GRL-UG-2.2.0.295.pdf page no 256           

         C:/ti/TivaWare_C_Series-2.1.4.178/docs/SW-TM4C-GRL-UG-2.2.0.295.pdf.

when i am image convert in RBG mode then Command Prompt window  show the messege  pnmtoc: Image contains too many colors!

in that mention procedure to convert a PNM image into a C array but it is limited to color index 256 and my image is more than 256 color how can convert that into  PNM image to a C array using more than 256 color 
   

i hope you are understand my problem.

file:///C:/ti/Tivre_C_Series-2

.1.4.178/docs/SW-TM4C-GRL-UG-2.2.0.295.pdf_C_Series-2.1.4.178/docs/SW-TM4C-GRL-UG-2.2.0.295.pdf

d

  • Hi,

    Please see below explanation. 

    1. Load the file (File->Open).
    2. Convert the image to indexed mode (Image->Mode->Indexed). Select “Generate optimum
    palette” and select either 2, 16, or 256 as the maximum number of colors (for a 1 BPP, 4 BPP,
    or 8 BPP image respectively). If the image is already in indexed mode, it can be converted to
    RGB mode (Image->Mode->RGB) and then back to indexed mode.
    3. Save the file as a PNM image (File->Save As). Select raw format when prompted.
    4. Use pnmtoc to convert the PNM image into a C array.
    This sequence will be the same for any source image type (GIF, BMP, TIFF, and so on); once loaded
    into GIMP, it will treat all image types equally. For some source images, such as a GIF which is
    naturally an indexed format with 256 colors, the second step could be skipped if an 8 BPP image is
    desired in the application.

    You can also refer to the source code at C:\ti\TivaWare_C_Series-2.2.0.295\tools\pnmtoc\pnmtoc.c file. 

    //
    // Is this a bitmap?
    //
    if(!bBitmap)
    {
    //
    // No - get the number of distinct colors in the image.
    //
    GetNumColors(pui8Data + ui32Max, ui32Width, ui32Height, bMono);

    //
    // Determine how many colors are in the image.
    //
    if(g_ui32NumColors <= 2)
    {
    //
    // There are 1 or 2 colors in the image, so encode it with 1 bit
    // per pixel.
    //
    ui32Length = Encode1BPP(pui8Data + ui32Max, ui32Width, ui32Height,
    bMono);
    }
    else if(g_ui32NumColors <= 16)
    {
    //
    // There are 3 through 16 colors in the image, so encode it with
    // 4 bits per pixel.
    //
    ui32Length = Encode4BPP(pui8Data + ui32Max, ui32Width, ui32Height,
    bMono);
    }
    else if(g_ui32NumColors <= 256)
    {
    //
    // There are 17 through 256 colors in the image, so encode it with
    // 8 bits per pixel.
    //
    ui32Length = Encode8BPP(pui8Data + ui32Max, ui32Width, ui32Height,
    bMono);
    }
    else
    {
    //
    // There are more than 256 colors in the image, which is not
    // supported.
    //
    fprintf(stderr, "%s: Image contains too many colors!\n",
    basename(argv[0]));
    return(1);
    }
    }

  • I see that pnm.c file but my image is more than 256 color how can convert pnm image to c array..

  • Hi,

      I think in GIMP you can save for 256 colors or less. 

  • in my image more color when I am creating 256 image index then image quality is down . I want to improve my image quality.
    please any suggestions for the best quality image produces with c array. 

  • Hi,

     The pnmtoc utility only limits to 256 colors. Perhaps you can do Google search if there are any online tools that will convert your images to C array per your use case.