DSPRelated.com
Forums

Display of bmp image on TMS320C6711

Started by er_narin November 3, 2004


Hello ! I am trying to display an image on TMS320C6711 processor.I am
not able to display the image properly. Infact I am getting sometimes
three images of input image or I am getting some small portion of the
input image. The code I am trying out is #include<stdio.h>

typedef struct
{
unsigned char signature[2];
long filesize;
long reserved;
long dataoffset;
}filehead;

typedef struct
{
long header_size;
long width;
long height;
unsigned planes;
unsigned bitcount;
long compression;
long imagesize;
long hres;
long vres;
long color_used;
long imp_color;
}infohead;

void main()
{

long rows;
long cols;
filehead fileh;
infohead infoh;
int i,j;
unsigned char *r,*g,*b;
int cnt=0,*Out;
unsigned char pixel;
FILE *fp;
fp=fopen("c:\\baby3.bmp","rb");
fread(&fileh.signature,2,1,fp);
fread(&fileh.filesize,4,1,fp);
fread(&fileh.reserved,4,1,fp);
fread(&fileh.dataoffset,4,1,fp); fread(&infoh.header_size,4,1,fp);
fread(&infoh.width,4,1,fp);
fread(&infoh.height,4,1,fp);
fread(&infoh.planes,2,1,fp);
fread(&infoh.bitcount,2,1,fp);
fread(&infoh.compression,4,1,fp);
fread(&infoh.imagesize,4,1,fp);
fread(&infoh.hres,4,1,fp);
fread(&infoh.vres,4,1,fp);
fread(&infoh.color_used,4,1,fp);
fread(&infoh.imp_color,4,1,fp);
fseek(fp,fileh.dataoffset,0);
rows=infoh.height;
cols=infoh.width;

cnt=cols%4;
printf("\n filesize=%d",fileh.filesize);
printf("\n dataoffset=%d",fileh.dataoffset);
printf("\n header_size=%d",infoh.header_size);
printf("\n cols=%d",infoh.width);
printf("\n rows=%d",infoh.height);
printf("\n imagesize=%d",infoh.imagesize);
printf("\n color_used=%d",infoh.color_used);
printf("\n imp_color=%d",infoh.imp_color);
r=(unsigned char *)malloc(rows*cols);
g=(unsigned char *)malloc(rows*cols);
b=(unsigned char *)malloc(rows*cols);
Out=(int *)malloc(rows*cols);

for(i=rows-1;i>=0;i--)
{
for(j=cols-1;j>=0;j--)
{
pixel=getc(fp);
r[i*cols+j]=(unsigned char)pixel;
g[i*cols+j]=(unsigned char)pixel;
b[i*cols+j]=(unsigned char)pixel;

}
}
}




long is 40-bits on C6x. Rather use int-32 bits. If you
truly need the 40-bit use %ld when printing to a file.

Regds
JS
>er_narin wrote:
>
> Hello ! I am trying to display an image on TMS320C6711 processor.I am
> not able to display the image properly. Infact I am getting sometimes
> three images of input image or I am getting some small portion of the
> input image. The code I am trying out is
>
> #include<stdio.h>
>
> typedef struct
> {
> unsigned char signature[2];
> long filesize;
> long reserved;
> long dataoffset;
> }filehead;
>
> typedef struct
> {
> long header_size;
> long width;
> long height;
> unsigned planes;
> unsigned bitcount;
> long compression;
> long imagesize;
> long hres;
> long vres;
> long color_used;
> long imp_color;
> }infohead;
>
> void main()
> {
>
> long rows;
> long cols;
> filehead fileh;
> infohead infoh;
> int i,j;
> unsigned char *r,*g,*b;
> int cnt=0,*Out;
> unsigned char pixel;
> FILE *fp;
> fp=fopen("c:\\baby3.bmp","rb");
> fread(&fileh.signature,2,1,fp);
> fread(&fileh.filesize,4,1,fp);
> fread(&fileh.reserved,4,1,fp);
> fread(&fileh.dataoffset,4,1,fp);
>
> fread(&infoh.header_size,4,1,fp);
> fread(&infoh.width,4,1,fp);
> fread(&infoh.height,4,1,fp);
> fread(&infoh.planes,2,1,fp);
> fread(&infoh.bitcount,2,1,fp);
> fread(&infoh.compression,4,1,fp);
> fread(&infoh.imagesize,4,1,fp);
> fread(&infoh.hres,4,1,fp);
> fread(&infoh.vres,4,1,fp);
> fread(&infoh.color_used,4,1,fp);
> fread(&infoh.imp_color,4,1,fp);
> fseek(fp,fileh.dataoffset,0);
> rows=infoh.height;
> cols=infoh.width;
>
> cnt=cols%4;
> printf("\n filesize=%d",fileh.filesize);
> printf("\n dataoffset=%d",fileh.dataoffset);
> printf("\n header_size=%d",infoh.header_size);
> printf("\n cols=%d",infoh.width);
> printf("\n rows=%d",infoh.height);
> printf("\n imagesize=%d",infoh.imagesize);
> printf("\n color_used=%d",infoh.color_used);
> printf("\n imp_color=%d",infoh.imp_color);
> r=(unsigned char *)malloc(rows*cols);
> g=(unsigned char *)malloc(rows*cols);
> b=(unsigned char *)malloc(rows*cols);
> Out=(int *)malloc(rows*cols);
>
> for(i=rows-1;i>=0;i--)
> {
> for(j=cols-1;j>=0;j--)
> {
> pixel=getc(fp);
> r[i*cols+j]=(unsigned char)pixel;
> g[i*cols+j]=(unsigned char)pixel;
> b[i*cols+j]=(unsigned char)pixel;
>
> }
> }
> } > _____________________________________
> Note: If you do a simple "reply" with your email client, only the author of
this message will receive your answer. You need to do a "reply all" if you want
your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://www.yahoogroups.com/group/c6x
>
> Other Groups: http://www.dsprelated.com
>
> Yahoo! Groups Links >
>




Where do you want to display the image? You want to display it once to view
it in CCS with view/graph/image? Or you want to output it continously?

You open a file on your harddisk from the DSP? How is your PC connected to
the DSP? I suppose its Jtag. Maybe the reason for troubles is the
communication between PC and the DSP. Can you give us some more details
about your hardware configuration?

In case you are thinking about outputting your image to some output from the
DSP directly: For example - in good old monochrome standard PAL, you have
768x576 Pixels, along with the blank lines maybe 64s to process one line to
meet the real time targets. Maybe you want to have 50% idle time after
reading in and outputting the image you have maybe 15s to process one line
of maybe 900 Pixels (including blanks). In your loop you touch each and
every pixel one by one. I doubt that this will be fast enough. In one of my
projects I copy the data using EDMA to a Fifo (in a Xilinx-PLD), this takes
about 8-10s for a line with 32Bit transfers including some overhead like
checking linenumbers...

bye,

thomas

> Hello ! I am trying to display an image on TMS320C6711 processor.I am
> not able to display the image properly. Infact I am getting sometimes
> three images of input image or I am getting some small portion of the
> input image. The code I am trying out is > #include<stdio.h>
>
> typedef struct
> {
> unsigned char signature[2];
> long filesize;
> long reserved;
> long dataoffset;
> }filehead;
>
> typedef struct
> {
> long header_size;
> long width;
> long height;
> unsigned planes;
> unsigned bitcount;
> long compression;
> long imagesize;
> long hres;
> long vres;
> long color_used;
> long imp_color;
> }infohead;
>
> void main()
> {
>
> long rows;
> long cols;
> filehead fileh;
> infohead infoh;
> int i,j;
> unsigned char *r,*g,*b;
> int cnt=0,*Out;
> unsigned char pixel;
> FILE *fp;
> fp=fopen("c:\\baby3.bmp","rb");
> fread(&fileh.signature,2,1,fp);
> fread(&fileh.filesize,4,1,fp);
> fread(&fileh.reserved,4,1,fp);
> fread(&fileh.dataoffset,4,1,fp); > fread(&infoh.header_size,4,1,fp);
> fread(&infoh.width,4,1,fp);
> fread(&infoh.height,4,1,fp);
> fread(&infoh.planes,2,1,fp);
> fread(&infoh.bitcount,2,1,fp);
> fread(&infoh.compression,4,1,fp);
> fread(&infoh.imagesize,4,1,fp);
> fread(&infoh.hres,4,1,fp);
> fread(&infoh.vres,4,1,fp);
> fread(&infoh.color_used,4,1,fp);
> fread(&infoh.imp_color,4,1,fp);
> fseek(fp,fileh.dataoffset,0);
> rows=infoh.height;
> cols=infoh.width;
>
> cnt=cols%4;
> printf("\n filesize=%d",fileh.filesize);
> printf("\n dataoffset=%d",fileh.dataoffset);
> printf("\n header_size=%d",infoh.header_size);
> printf("\n cols=%d",infoh.width);
> printf("\n rows=%d",infoh.height);
> printf("\n imagesize=%d",infoh.imagesize);
> printf("\n color_used=%d",infoh.color_used);
> printf("\n imp_color=%d",infoh.imp_color);
> r=(unsigned char *)malloc(rows*cols);
> g=(unsigned char *)malloc(rows*cols);
> b=(unsigned char *)malloc(rows*cols);
> Out=(int *)malloc(rows*cols);
>
> for(i=rows-1;i>=0;i--)
> {
> for(j=cols-1;j>=0;j--)
> {
> pixel=getc(fp);
> r[i*cols+j]=(unsigned char)pixel;
> g[i*cols+j]=(unsigned char)pixel;
> b[i*cols+j]=(unsigned char)pixel;
>
> }
> }
> } >
> _____________________________________
> Note: If you do a simple "reply" with your email client, only the author
> of this message will receive your answer. You need to do a "reply all" if
> you want your answer to be distributed to the entire group.
>
> _____________________________________
> About this discussion group:
>
> To Join: Send an email to
>
> To Post: Send an email to
>
> To Leave: Send an email to
>
> Archives: http://www.yahoogroups.com/group/c6x
>
> Other Groups: http://www.dsprelated.com
>
> Yahoo! Groups Links >
>

--
NEU +++ DSL Komplett von GMX +++ http://www.gmx.net/de/go/dsl
GMX DSL-Netzanschluss + Tarif zum supergstigen Komplett-Preis!



Yes, I've seen your query in the Yahoo forum. I haven't a clear answer for
that, but my suggestion is don't use the standard I/O library, because it
assumes there is an easy path between the hard disk and the DSP, which isn't
always true. In addition, I don't know what kind of board you are using
(DSK, EVM, user defined). Instead, I would convert the image into a TI
format, and load it using file->data->load in CCS or a GEL function. Hava a
look at the help to see how's the TI format hex file defined.

-----Mensaje original-----
De: er_narin [mailto:]
Enviado el: jueves, 04 de noviembre de 2004 4:50
Para:
Asunto: Display of bmp image on TMS320C6711
Hello friend I am trying to read a bmp image from disk and want to
display it with view option on CCS. My problem is I am not able to
display the image properly. Can you send me some C code for the same.