SRL Archive - C/C++ Help and Tutorials

c++ Help ha.


SKy Scripter

2009-07-09 05:14:01

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) { 

this->richTextBox1->Text = L"Analyzing Picture...";
// StartA();

int w = this->pictureBox1->Width;
int h = this->pictureBox1->Height;

for (int y=0; y<h; y++)
{
for (int x=0; x<w; x++){

};

};



Essentially i would like to get a pixel from a certain position from picture box
because i want to place each pixel into an array…

any help?

im really new to c++…

thanks

_ChArMz

2009-07-11 23:28:58

use GetPixel, CreateDIBSection, or GEtDIBits and Bitblt NOOB!

noidea

2009-07-12 10:08:54

From: Da 0wner
Wtf. You post like once every week (maybe even less) Charmz :p.


We are lucky he is here :)

rogue poser

2009-07-13 11:13:18

From: _ChArMz
use GetPixel, CreateDIBSection, or GEtDIBits and Bitblt NOOB!


Too add to this, do not use get pixel, bitblt and getdibits would work the best for quick processing, but its a bit tricky to get it working, there are plenty of tuts

boberman

2009-07-19 19:52:01

From: rogue poser
Too add to this, do not use get pixel, bitblt and getdibits would work the best for quick processing, but its a bit tricky to get it working, there are plenty of tuts


That depends. If you just want 2 pixels, then there is no reason to use bitblt and getdibits. If you are editing or looking at the whole image then yes you definitally should use bitblt and getdibits.

Is that valid C++ code you posted (IE does it compile?) it looks like you have loads of syntax errors.

Either way, I would consider checking out the MSDN and learning how to get a bitmap from a picture box. (As I'm fairly sure you are using MSVC).

System::Void button1_Click(System::Object&  sender, System::EventArgs&  e) { 

this->richTextBox1->Text = L"Analyzing Picture...";
// StartA();

int w = this->pictureBox1->Width;
int h = this->pictureBox1->Height;

for (int y=0; y<h; y++)
{
for (int x=0; x<w; x++){

};

};

SKy Scripter

2009-07-28 01:42:43

okay so i figured out a long time ago sorry i should have post this XD.

Charmz is just trying to make me look stupid but failing at it. you nub haha

btw i wasn't looking for speed so i don't really care that i used get pixel


private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {

Image ^img;
Bitmap ^bmp;

richTextBox1->Text = L"Analyzing Picture... \n";

img = pictureBox1->Image;

bmp = gcnew Bitmap(img);

int w = 0;
int h = 0;

w = bmp->Width;
h = bmp->Height;


// Store Each Pixel Into an Array of Data
for (int y=0; y<h; y++)
{
for (int x=0; x<w; x++){
c[x][y] = ColorTranslator::ToWin32(bmp->GetPixel(x, y));
};
}


// Edge Detection Algorithm
for (int y=1; y<h; y++){
for (int x=1; x<w; x++){

if (c[x][y] == 16777215) {
for (int i=0; i<8; i++) {
if (c[x + ax[i]][y + ay[i]] == 0) {
c[x][y] = 255;
}
}
}
}
};

richTextBox1->AppendText("Detected Edges" );


// Skyler's Pixel Algorithm



for (int y=0; y<h; y++) {
for (int x=0; x<w; x++){
bmp->SetPixel(x, y, ColorTranslator::FromWin32(c[x][y]));
};
}

// getbitma
// BitBlt(pictureBox1->Handle, 0, 0, w, h, handle, 0, 0, SRCCOPY);
//
pictureBox1->Image = bmp;

}