473,467 Members | 1,300 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

RAW Image data reading ERROR

I read RAW image data from a binary file stream. I have to read just
bytes one by one and put them into a matrix of structs of unsigned
chars.
I have to use unsigned chars because their rangs go from 0 to 255. If
I use chars then a value of 129 will be -128 :(

The problem:

infile.get(ImageDATA[i][j].R);

Reads only chars... Ok, it works fine with chars, but when I access to
the matrix the value is read like char... but i want rang from 0 -
255...

Help meeeeee

The source is something like that:

#include <iostream>
#include <fstream>
#include <ctime>
#include <stdlib.h>

using namespace std;

struct structRGB {
unsigned char R;
unsigned char G;
unsigned char B;
};

structRGB ImageDATA[576][720];

int main(int argc, char *argv[]) {

int i,j;
ifstream infile;
ofstream outfile;

infile.open("image.raw", ios::binary);
for(i=0; i<576; i++) {
for(j=0; j<720; j++) {
infile.get(ImageDATA[i][j].R);
infile.get(ImageDATA[i][j].G);
infile.get(ImageDATA[i][j].B);
}
}
infile.close();
outfile.open("copy.raw", ios::binary);
for(i=0; i<576; i++) {
for(j=0; j<720; j++) {
outfile.put(ImageDATA[i][j].R);
outfile.put(ImageDATA[i][j].G);
outfile.put(ImageDATA[i][j].B);
}
}

outfile.close();
system("PAUSE");
return 0;
}
Jul 22 '05 #1
1 4747
Joan wrote:
I read RAW image data from a binary file stream. I have to read just
bytes one by one and put them into a matrix of structs of unsigned
chars.
I have to use unsigned chars because their rangs go from 0 to 255. If
I use chars then a value of 129 will be -128 :(

The problem:

infile.get(ImageDATA[i][j].R);

Reads only chars...


How about

ImageData[i][j].R = infile.get();

istream::get() returns an int, which is plenty.

Jonathan
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
4
by: Andy | last post by:
Hello All: I have a field in the database that is an Image. I have no idea how the data is stored in here (Image, compressed, encrypted, plain text, etc). I am trying to write the contents to...
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...
2
by: Chucker | last post by:
Hi Community, I think I can store Binary Data in SQL Server but when I try to retrieve it, I always only get one byte. I think I stored my Binary Data in SQL Server in a Colum of Type Image....
3
by: anewbie | last post by:
hi. ive been searching for help with storing images in access. after much hunting i found this bit of code that Cor Ligthert put up on another forum. but when i try to update to the dataset, i...
2
by: Ed | last post by:
Hope someone can help me out... I have been tasked to read some image data from an sql database and save the files to flat files. OK, sounds easy as I'v used BLOBs before. But this is an old...
2
by: Adam Teale | last post by:
hey guys Is there a builtin/standard install method in python for retrieving or finding out an image's dimensions? A quick google found me this:...
70
by: quickcur | last post by:
hi can anyone explain me to read image to memory from a url it is very easy in java but it is hard to find an complete solution in c/c++. Thanks,
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.