Creating a .ppm file

Guest #3388261
Rate this post
• ▲ useful
▼ not useful
Hi all

I find difficulty in creating an Image file of .ppm format. I tried 
writing a file with rgb data in hex format. But when written the image 
is wrong . I just get a grayscale image.

When I tried opening a random .ppm image in text format it is not in 
human readable format.

I am still trying to find in what format the data is written into the 
file. (binary and hex did not work).

Please help.

Thanks in advance

Code:
  ppm_file : process
  file ppm_file : TEXT ;
  variable l_handle : line ;
  variable P6    : string(1 to 2 ) := "P6";
  variable name  : string(1 to 17) := "# ppm image";
  variable size  : string (1 to 7) := "800 480";
  variable space : string (1 to 1) := " ";
  variable scope : string (1 to 3) := "255";
  VARIABLE char : integer:= 0;
  begin

    file_open(ppm_file,"image_ppm",write_mode);

        write(l_handle,P6);
        writeline(ppm_file,l_handle);
        write(l_handle,name);
        writeline(ppm_file,l_handle);
        write(l_handle,size);
        writeline(ppm_file,l_handle);
        write(l_handle,scope);
        writeline(ppm_file,l_handle);

    loop
      wait until(rising_edge(clk));

         write(l_handle, (to_hstr(red))); write(l_handle, space);
         write(l_handle, (to_hstr(green))); write(l_handle, space);
         write(l_handle, (to_hstr(blue)));write(l_handle, space);

         writeline(ppm_file,l_handle);
    end loop ;
    file_close(ppm_file);
  end process ppm_file;
Guest #3390465
Rate this post
• ▲ useful
▼ not useful
Stuart wrote:
> When I tried opening a random .ppm image in text format it is not in
> human readable format.
>
> I am still trying to find in what format the data is written into the
> file. (binary and hex did not work).

According to http://en.wikipedia.org/wiki/Netpbm_format is P6 the 
identifier for binary and P3 for readable ASCII.

I suggest to start with ASCCI (P3).

Duke

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.