Image file read

In reply to dave_59:

Dave,

My requirement is to read from a ASCII formatted input image file and write the data to another ASCII formatted output image file.
I used a 800*600 *.raw(RGB formatted ASCII) file. I used IrfanView tool to generate *.raw(RGB) from *.JPG.

here is my full code. If wanted i can send the input image file as attachment.
I don’t see an option to attach files here in this forum how?

class input_video_IF;
    int data;
    int count;
    integer input_file, file_status,output_file,read_char;
	reg [7:0]data_byte;
	
    function new ();
	
	 	input_file = $fopen("test_800.raw","r");
		
		if(input_file)
		begin
		   $display("File OPENED");
		end
		else
		begin
		   $display("File error");
		end
	    endfunction:new 
	

	
	function void image_file_read();
            count = 0;
            while ((data = $fgetc(input_file)) != -1) // raw binary
				$display("fgetc:%0d %h %d",data, data , count);
            $fclose(file_status);
           /*  file_status = $fopen("input_file","r");
            while ($fscanf(file_status,"%h",data) != -1) // hex formatted
	            $display("fscanf: %h",data);
            $fclose(file_status); */
    endfunction : image_file_read

		
	endclass

program Image_read_test;
int input_file;
input_video_IF In_IF = new();
initial
    In_IF.image_file_read();

endprogram

Thanks!