2012100016
(usa Outra)
Enviado em 14/06/2016 - 19:51h
Segue o inicio do código:
#include <stdio.h>
int main()
{
FILE *torres;
FILE *aline;
unsigned char imagem[64][64];
int l,c; /* linha e coluna */
//Abre o arquivo de entrada
if((torres = fopen("bmp_1bits.bmp","r")) == NULL)
{
printf("Impossivel de abrir o arquivo.\n");
}
else
{
//Coloca as informações do arquivo em uma matriz chamada imagem[][]
for(l=0;l<64;l++)
{
for(c=0;c<64;c++)
{
imagem[l][c]=(unsigned char) fgetc (torres);
}
}
fclose(torres);
// Apontando para outro arquivo
if((aline = fopen("farol_1bits.jpg","r")) == NULL)
{
printf("Impossivel de abrir o arquivo.\n");
}
else
{
//Coloca as informações do arquivo em uma matriz chamada imagem[][]
for(l=0;l<64;l++)
{
for(c=0;c<64;c++)
{
imagem[l][c]=(unsigned char) fgetc (sergio);
}
}
fclose(sergio);
}
//Abre o arquivo de saida
if((torres = fopen("bmp_out.bmp","w")) == NULL){
printf("Impossivel de abrir o arquivo.\n");
}
else {
//Guarda as informações da matriz imagem em um arquivo de saida
for(l=0;l<64;l++)
{
for(c=0;c<64;c++)
{
fputc((unsigned char) imagem[l][c], torres);
//Imprime na tela o conteudo da matriz
printf("%d ",imagem[l][c]);
}
printf("\n");
}
if((aline = fopen("farol_1bits.jpg","w")) == NULL){
printf("Impossivel de abrir o arquivo.\n");
}
else {
//Guarda as informações da matriz imagem em um arquivo de saida
for(l=0;l<64;l++)
{
for(c=0;c<64;c++)
{
fputc((unsigned char) imagem[l][c], aline);
//Imprime na tela o conteudo da matriz
printf("%d ",imagem[l][c]);
}
printf("\n");
}
}
return(0);
}