By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,171 Members | 943 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,171 IT Pros & Developers. It's quick & easy.

Image Read and Display

P: 79
I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!
Mar 13 '07 #1
Share this Question
Share on Google+
7 Replies


P: 3
suppose ur file name is spect.dat. first we study that image in program as follows
int *p;
p = sizeof(int) malloc(sizeof(int)*128*128*120);
FILE *INPUT,*OUTPUT;
INPUT = fopen("spect.dat","rb");
OUTPUT = fopen("spectoutput.dat","wb");
fread(p,sizeof(int)*1,1,INPUT);
fwrite(p,sizeof(int)*1,1,OUTPUT);

description;
line 2; suppose our image is 128*128 with 120 projection, the we allocate memory space for that.
line 5;
we read the image from spect.dat file and it stored in p.

line 6; we see the same image in program. ie., our input image in our programme. From p we read that image and stored in OUTPUT ie., we see the image in the spectoutput.dat.
wb- write binary from pointer.
rb - read binary from outside file.
Mar 14 '07 #2

P: 3
are u know about how to convert 3D pointer to 1D pointer. Please send reply.
Mar 14 '07 #3

saranjegan
P: 51
I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!

whats the type of image you are to open it may differ respect to types
Mar 14 '07 #4

P: 79
are u know about how to convert 3D pointer to 1D pointer. Please send reply.
1. For the codes about fread, fopen and fwrite, to make it executable in MSVC++, should I place it inside a cpp file like this and put the bat file under the same folder of cpp file? I failed to do that in MSVC++.

#include <stdio.h>
using namespace std;
int main () {
// the block of codes you mentioned
}

2. I am quite confused of what template I should choose in New Project in such occasion? MFC Application or Win32 Project?

3. Do you mean the 2D array assignment like this?

#define WIDTH 5
#define HEIGHT 3

int Tommy [HEIGHT][WIDTH];
int n,m;

int main ()
{
for (n=0;n<HEIGHT;n++)
for (m=0;m<WIDTH;m++)
{
jimmy[n][m]=(n+1)*(m+1);
}
return 0;
}


whats the type of image you are to open it may differ respect to types
Actually, what I am doing is to read in a binary image file, say jpg, bmp, etc. for later processing. Or simply a file created by notepad filled with 1 & 0.
Mar 14 '07 #5

P: 79
I have no previous programming experience, no formal teaching materials received and no teacher's guidance. But I have to do all that on my own. Everything I can do is to research on my own. Please give me some instruction. I get lost and have a big difficulty in such conceptual level.

Help ! Please !
Mar 15 '07 #6

saranjegan
P: 51
I have no previous programming experience, no formal teaching materials received and no teacher's guidance. But I have to do all that on my own. Everything I can do is to research on my own. Please give me some instruction. I get lost and have a big difficulty in such conceptual level.

Help ! Please !



1.Select the format of file which you are about to open and read

2.if you select BMP format of files it may be easy for you to work with that
( first study the format of the bmp file google with bmp file struct u may get some tutorials)

3.Study the format of bmp file it has header information for first 14 bytes read them using fread function and put in a struct or array

3.secondly it has header file info for the next 40 bytes you read that too and have it

4.now you can play with the image with these details .it will be more easy if you are working in VC++ there are lot of function for this look for msdn libraries
use SetDIBitsToDevice function
you can try by yours
Mar 15 '07 #7

P: 1
Hello All,

Can any one tell me how to open a 2 - bit binary Image file in C after getting both the file and info headers and the colormap. The problem is with reading the pixel data using fgetc( ). This function reads one byte at a time from the file and since a 32 x 32 binary image has 1024 pixels, each represented by 2 bits, the function perhaps produces a mismatch between the amount of data being read and the data present in the file. How to resolve this problem.

Anurag Mishra


I am a newbie.

In MSVC++ 2005, how can I read in an image (say binary or even grayscale/color) and then display it in a window after some image processing?? I know something like MFC can ease the task.I also know something like image buffer and array. Which one is better? How to implement?

I really have no idea, even I have read a lot of materials. Please help!! Give me some instruction! Thanks!!
Mar 24 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.