BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Using scanline to fill an array [][]

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics)
View previous topic :: View next topic  
Author Message
Pedro Alves
Guest





PostPosted: Tue Nov 23, 2004 2:31 pm    Post subject: Using scanline to fill an array [][] Reply with quote



Hi,

I'm trying to use scanline with a bitmap picture in order to fill and
array[][] of the size of the picture with all its information (pixel
data).

For that I:

void __fastcall TForm1::Button1Click(TObject *Sender)
{
<<< setting up calculations and files to receive those
calculations
Quote:


bitmap1 = new Graphics::TBitmap();

bitmap1->LoadFromFile(FileListBox1->FileName);
Image1->Canvas->Draw(0,0,bitmap1);

bitmap1->PixelFormat = pf8bit;

m = bitmap1->Height; //rows y m j
n = bitmap1->Width; //cols x n k


float **data; // Original image pixels

try {
data = new float*[m];
for (int j = 0; j < m; j++)
data[j] = new float[n];
}
catch(...) {
ShowMessage("Could not allocate for data[][]. Bye for now!");
exit(-1);
};

With this array data, I use scanline and two for cycles (the usual) to
go through each element and keep it in data[m][n]

What happens is that I can do this with a 256x256 pixels picture but
not with a 100x100 or a rectangle picture.
I think I'm getting very confused and I might have some other errors
on my code.

Is there and easier way to:
1) create a array the size of the picture (using the operator new
making it width and height independent)?

2) Use scanline to go through the picture and save it the array?

I'm a newbie on this.

Thanks for the help.

Pedro

[email]alves_pmf (AT) yahoo (DOT) com.br[/email]

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Graphics) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.