Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

read pixel values out of ascii file

Status
Not open for further replies.

tougo

Technical User
Sep 9, 2002
27
GB
I've made a programme that reads and displays images
I wanted to be able to save the image in ASCII format, so as to be able to view the value of each pixel so I ended up with this code

.
.
.
int x = mImage->get_Width();
int y = mImage->get_Height();
pic1->ClientSize = System::Drawing::Size(x,y);
ClientSize = System::Drawing::Size((x)+20,(y)+40);

for (int Xcount = 0; Xcount < mImage->Width; Xcount=Xcount+1)
for (int Ycount = 0; Ycount < mImage->Height; Ycount=Ycount+1)
{
Color xsx = mImage->GetPixel(Xcount,Ycount);
String* zxc = xsx.ToString();
br->WriteLine(zxc);
}
br->Flush();
br->Close();
.
.
.

and the ASCII file looked like this:

Color [A=255, R=213, G=148, B=110]
Color [A=255, R=222, G=162, B=134]
Color [A=255, R=215, G=163, B=141]
Color [A=255, R=227, G=178, B=161]
Color [A=255, R=244, G=195, B=180]
Color [A=255, R=248, G=199, B=185]
Color [A=255, R=250, G=207, B=198]
Color [A=255, R=250, G=207, B=198]
.
.
.

Now I want to be able to open the ASCII file and display the image (the original values of the image have been altered)
and I've come so far with this (note: the images have always the same dimensions 430x286 and 122980 is the lines of the ASCII file)

.
.
.
String* fs = pOFD->FileName;
FileStream* s2 = new FileStream(fs, FileMode::Open, FileAccess::Read);
StreamReader* ss1 = new StreamReader(s2);
for (int skee = 0; skee < 122980; skee = skee+1)
ss1->BaseStream->Seek(skee,SeekOrigin::Begin);
String* line = ss1->ReadLine();
for (int Xcount = 0; Xcount < 430; Xcount=Xcount+1)
for (int Ycount = 0; Ycount < 286; Ycount=Ycount+1)
mImage->SetPixel(Xcount, Ycount, line);
.
.
.
the problem is that line is a string and note a color value , so that thing doesn't work
not that if line was a color value would work.

any ideas? any help appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top