how to read a .bmp image file in VHDL

Status
Not open for further replies.

raghava

Member level 2
Joined
Jul 31, 2008
Messages
51
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Activity points
1,870
Hi all,

How to read a 24 bit bmp file in VHDL. This is the code I have written.
Here also exit when endfile is needed na????

***********************
procedure bmp_read is
variable inline: line;
variable b:character;
variable g:character;
variable r:character;
variable end_of_line:boolean;

type char_file is file of character;
file file_bmp : char_file open READ_MODE is "../data/input/lena_64_64.bmp";
begin

while not endfile(file_bmp) loop
readline(file_bmp, inline);
read(inline, b);
read(inline, g);
read(inline, r);
-- body
end loop;

file_close(file_bmp);
end bmp_read;

Added after 2 hours 23 minutes:

HI all,

I am expecting your valuable answers.

Regards
 

HI all,

Its working. Here is the code.

procedure bmp_read is
variable inline: line;
variable b:character;
variable g:character;
variable r:character;
variable end_of_line:boolean;

type char_file is file of character;
file file_bmp : char_file open READ_MODE is "../data/input/lena_64_64.bmp";
begin

while not endfile(file_bmp) loop
read(inline, b);
read(inline, g);
read(inline, r);
end loop;

file_close(file_bmp);
end bmp_read;
 
how to use this code posted by raghava? can anyone tell me. my project is sobel edge detection using vhdl. i am almost done with my code. but i am not knowing how to call image and after making changes how to display it.
 

how to use this code posted by raghava? can anyone tell me. i want to read an image and feed it to a verilog code pixel by pixel, do some arithmetic operations and redisplay it as an image.
 

how to use this code posted by raghava? can anyone tell me. i want to read an image and feed it to a verilog code pixel by pixel, do some arithmetic operations and redisplay it as an image.

i have tried writing a similar version of raghava's code. it intends to read only the first byte of the sample bmp image. but i get an error as "Only SHARED variables can be declared here." at line 42. can u help decode the problem. here's my code.


entity first is

port(
a: in std_logic
);

end first;

architecture Behavioral of first is

variable c: character; ---- line 42
TYPE sample IS FILE OF character;
FILE f:sample open read_mode IS "C:\Documents and Settings\first\sample.bmp";
begin

read(f,c);

end Behavioral;
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…