473,401 Members | 2,068 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,401 software developers and data experts.

C++ VB, How do you read from a picture (bmp/jpg.. etc) into an array

so far ive got

int width;
int height;
int bitdepth;
stringstream ss;
string str;
typedef unsigned char byte
int _tmain(int argc, _TCHAR* argv[])
{
str = argv[1];
stringstream(str) >> width;
str = argv[2];
stringstream(str) >> height;
str = argv[3];
stringstream(str) >> bitdepth;

ifstream inFile(argv[4], ios::in | ios::binary);

byte * array = new byte[width*height];

int * intA = new int[width*height];

int x;

while(x < width*height)
{
inFile >> array[x];
x++;
}
for(int k = 0; k < width*height; k++)
intA[k] = (int)array[k];

return 0;
}





when i run this with
rawread<width><height><bitdepth><filename> in the command line i get a multitude of "=" (equal) signs!?

help please, and ive just gotten to know C++ so simple is better. I just want to read a picture into an array of integers, so that i can do things like invert it by subtracting from 255 etc.... Thanks.
Jul 13 '07 #1
2 3259
archonmagnus
113 100+
Without interfacing APIs or image libraries, you'll need to review the file format specifications. I'd recommend starting with a bitmap image as it is the most "straight-forward" and easiest to implement. JPEG uses a discrete cosine transformation, quantization tables, and huffman tables to compress the image data--so you'd need to write the decompression routines first.

With bitmaps, the image data is stored (upside-down) starting at a 54 byte offset in the order Blue, Green, Red. The image width is stored as a four-byte long at bytes 18-21, the height is a four-byte long at bytes 22-25, and the bit-depth (or bit-count) is a two-byte short at bytes 28-29.

Here are a couple of links to more information regarding the bmp filetype specification:
http://www.fortunecity.com/skyscrape.../bmpffrmt.html
http://www.archonmagnus.com/computing/formats/bmp.php

I had a few PDF links, but I can't seem to find them. Sorry. I hope this will get you started though.
Jul 13 '07 #2
weaknessforcats
9,208 Expert Mod 8TB
Check out the SDK DirectX.
Jul 14 '07 #3

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

Similar topics

6
by: daimler | last post by:
help!!!!!!!! i did a for i=1 to picture1.scaleheight/2 picture1.pset (i,i) next i and the pset is shown on the picture
0
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id of the picture (an integer) and one (column named picture) is a field of type OLE Object which...
4
by: ColinWard | last post by:
Hello again. I am trying to figure out how to link a picture to a record from code. I have figured out how to get the proper dialogue box to open but I still have to manually check off the Link...
2
by: Lyn | last post by:
What is the best way to import a picture (bmp format) via VBA from a Windows file and embed it into a Bound Object Frame (and thence to an OLE Object in a table)? I found an MS knowledge base...
2
by: Lyn | last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph) with the following code which is based on MS article http://support.microsoft.com/?id=158941: strPathname =...
3
by: Sandi | last post by:
I have a simple problem: I have an Access database (images.mdb) that has 2 columns: one is the id if the picture (an integer) and one (column named picture) is a field of type OLE Object which...
5
by: Dean Slindee | last post by:
I have looked everywhere I can think of for the .exe name of the Windows Picture and Fax Viewer. Anybody know what it's named? Thanks, Dean Slindee
4
by: Elton | last post by:
Dear All, I am new to vb , please help. I have a picture , and a picture_click( ) function. What I want to do is to have a simulate a click event onto the picture in a loop. However, when I...
3
by: raghunadhs | last post by:
hi all! i have a picture box, in that picture box, there is a picture asume it as "pic1.bmp".. now i have made some changes in that picture. Now i want to load a picture to a image( my form...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.