Graph an image of a two-dimensional array

0

I am passing an image to a one-dimensional array. This must be passed to another two-dimensional array from which I must graph the saved image. the image has its beginning in 1078 and ends in 3078 , the problem that I have is to graph the image since it is running graph. This is the function that I have.

void pasoArreglo(FILE* Archivo) {

char datos[3078];
fread(datos, 1, 3078, Archivo);
char dimenciones[80][25];
for (int y = 0; y < 25; y++) {
    for (int x = 0; x < 80; x++) {
        dimenciones[x][y] = datos[1078 + ((y * 2) + x)];
    }
}

char Rcolor = 0, Gcolor = 0, Bcolor = 0;

for (int y = 24; y >= 0; y--) {
    for (int x = 0; x < 80; x++) {

        if (dimenciones[x][y] & 0x1) { Rcolor = FOREGROUND_RED; }
        if (dimenciones[x][y] & 0x2) { Gcolor = FOREGROUND_GREEN; }
        if (dimenciones[x][y] & 0x4) { Bcolor = FOREGROUND_BLUE; }

        gotoxy(x, y);
        setColor(Rcolor | Gcolor | Bcolor);
        printf("%c", 219);



        Rcolor = 0;
        Gcolor = 0;
        Bcolor = 0;
    }       
  }
}
    
asked by Edwin 26.11.2016 в 20:20
source

2 answers

0

I do not understand that "(and * 2) + x" ... should not be more "(and * 80) + x" ... that is "and * width of the image in bytes + x" ... I do not know if that will be the problem but I hope it can help ... Equal multiplication by 2 is because each color occupies 2 bytes instead of 1 ... if so I guess that the array is small for an image of 80x25 then 80x25 = 2000 bytes that are the ones you specify in the statement of the question (goes from 1078 to 3078) ... well ... I hope it can help ...

    
answered by 28.11.2016 в 03:31
-1
Algoritmo matriz_1
    definir n,f,c Como Entero
    definir matriz Como Entero
    dimension matriz(10,10)
    escribir 'digite n'
    leer n 
    para f<-1 hasta n con paso 1 hacer
    para c<-1 hasta n con paso 1 hacer
        escribir 'ingrese celda ','',f,'-',c
        leer matriz(f,c)
        FinPara
    FinPara

    para f<-1 hasta n con paso 1 Hacer
        para c<-1 hasta n con paso 1 hacer
            escribir Sin Saltar matriz(f,c),' '
        FinPara
        escribir ' '
    FinPara
FinAlgoritmo
    
answered by 27.11.2016 в 03:52