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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i organize one dimensional

Status
Not open for further replies.

julianluthor

Programmer
Nov 3, 2003
18
MY
how can i organize one dimensional array of data into multidimensional array.
here is my code:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int DataWidth = Image1->Picture->Width;
int DataHeight = Image1->Picture->Height;

for (int y=0;y<DataHeight;y++)
for (int x=0;x<DataWidth;x++)
Data[y][x] = (Byte)Image1->Canvas->Pixels[x][y];


TStringList*papar = new TStringList;
for (int j=0;j<400;j++)
for (int i=0;i<400;i++)
{
papar->Add(AnsiString(Data[j]));
}
papar->SaveToFile(&quot;Luthor.dat&quot;);
delete papar;
}

this code will give me result like this...
1
2
1
2
1
.
.
.

i want to make it as 400x400 array.thanks
 
Hey,
try this:
Code:
TStringList*papar = new TStringList;
AnsiString Temp = &quot;&quot;;
Temp.SetLength(400);

for(int j=1;j<=400;j++)
{
 for (int i=0;i<400;i++)
 {
  Temp[i] = (Byte)Image1->Canvas->Pixels[i][j];
 }
 papar->Add(Temp);
}

May not work, may not compile, but hope I could help....
onrdbandit
 
i've tried the code that you gave to me and can compile and load my image but i got this error in my file.h at this line...

ThrowIfOutOfRange(idx); // Should Range-checking be
optional to avoid overhead ??

what is that mean?
 
well, try this instead:
Code:
TStringList*papar = new TStringList;
AnsiString Temp = &quot;&quot;;

for(int j=1;j<=400;j++)
{
 for (int i=0;i<400;i++)
 {
  Temp = Temp + &quot; &quot;+ (Byte)Image1->Canvas->Pixels[i][j];
 }
 papar->Add(Temp);
 Temp = &quot;&quot;;
}

Sorry, this is off the top of my head, but it just MIGHT work....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top