473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Image Read and Display

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
7 4913
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
are u know about how to convert 3D pointer to 1D pointer. Please send reply.
Mar 14 '07 #3
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
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
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
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
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

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

Similar topics

2
by: Srinivas Chundi | last post by:
I have to display tif images using .asp page. I have tried to read the image as a binary file and stream it to the browser. The relevant code is as follows. Unfortunately, the display on the...
4
by: Dean L. Howen | last post by:
I create my own file format that could content many image files (jpg, ico, ....) . I can get the data of each image, and I want to display it on the form. How can? I've tried to create a file with...
3
by: dale zhang | last post by:
Hi, I am trying to read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp The article author is using PictureBox for windows...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
1
by: Adam | last post by:
I am having difficulty retrieving images from a SQL database. Here is the code I use to UPLOAD the image to the database: <form id="Form1" method="post" enctype="multipart/form-data"...
9
by: Sam | last post by:
hi, how to retrieve(display) and save image in sql server? thanks,
3
by: Neo Geshel | last post by:
Greetings. I am making an admin interface, which allows me to upload photos to an access DB. The admin interface also needs to display the uploaded photos, but only needs to show them at a...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
3
by: den 2005 | last post by:
Hi everyone, Here is code working on..Trying to insert record with a column with Image or VarBinary datatype in sql database from a existing jpeg image file, then retrieve this image from...
3
by: Froefel | last post by:
Hi group, I'm looking for some help on how to achieve the following in a gridview control that is based on an ObjectDataSource. The SelectMethod of the datasource returns a list of Customer...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.