Click here to Skip to main content
15,923,374 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: help me Pin
Peter Occil26-Jul-02 18:52
Peter Occil26-Jul-02 18:52 
GeneralRe: help me Pin
perlmunger27-Jul-02 5:21
perlmunger27-Jul-02 5:21 
GeneralRe: help me Pin
Tim Smith27-Jul-02 5:25
Tim Smith27-Jul-02 5:25 
GeneralGo Go Gadget Sockets!!! Pin
Ken Mazaika26-Jul-02 18:13
Ken Mazaika26-Jul-02 18:13 
GeneralUser define iostream manipulators with parameters Pin
oRion26-Jul-02 15:44
oRion26-Jul-02 15:44 
GeneralRe: User define iostream manipulators with parameters Pin
Christian Graus26-Jul-02 21:42
protectorChristian Graus26-Jul-02 21:42 
GeneralOpenGL related... Pin
niklo26-Jul-02 12:58
niklo26-Jul-02 12:58 
GeneralStack overflow in Gdiplus.dll Pin
Biff26-Jul-02 12:25
Biff26-Jul-02 12:25 
Hi,

I'm currently writing a method that is supposed to shape a region according to a color pattern in a supplied image. To do so I iterate through all the pixels in the image, but when I'm nearing the end, no matter the size of the image, I get an "First-chance exception in ImageRegion.exe (GDIPLUS.DLL): 0xC00000FD: Stack Overflow." exception. I'm new to GDI+ and I can't figure out what I'm doing wrong...

The method looks like this:

HRGN CRegionFromImage::FromFile( const WCHAR* filename, Color color )
{
	HDC hDC = ::GetDC( NULL );
	Graphics g( hDC );

	Bitmap* bitmap = Bitmap::FromFile( filename, FALSE );

	if ( bitmap == NULL ) return NULL;

	Rect rect( 0, 0, bitmap->GetWidth(), bitmap->GetHeight() );
	Region region( rect );
	BitmapData* bitmapdata = new BitmapData;

	bitmap->LockBits( &rect, ImageLockModeRead, PixelFormat32bppARGB, bitmapdata );

	UINT* pixels = (UINT*)bitmapdata->Scan0;

	for ( UINT y = 0; y < bitmap->GetHeight(); y++ )
	{
		for ( UINT x = 0; x < bitmap->GetWidth(); x++ )
		{
			Color pixelcolor( pixels[y * bitmapdata->Stride / 4 + x] );

			if ( color.GetR() == pixelcolor.GetR() && color.GetG() == pixelcolor.GetG() &&
				 color.GetB() == pixelcolor.GetB() )
			{
				Rect xorrect( x, y, 1, 1 );
				region.Xor( xorrect ); // EXCEPTION THROWN HERE!
			}
		}
	}

	bitmap->UnlockBits( bitmapdata );
	delete bitmapdata;

	return region.GetHRGN( &g );
}


Thanks,

biff
QuestionCould I subclass CListCtrl in My CListView class Pin
Stas26-Jul-02 9:15
Stas26-Jul-02 9:15 
GeneralPlaying wave files Pin
Luis E. Cuadrado26-Jul-02 8:52
Luis E. Cuadrado26-Jul-02 8:52 
GeneralRe: Playing wave files Pin
Anonymous26-Jul-02 9:51
Anonymous26-Jul-02 9:51 
GeneralRe: Playing wave files Pin
Alexandru Savescu27-Jul-02 1:16
Alexandru Savescu27-Jul-02 1:16 
QuestionHow to kill a thread from DllMain Pin
Anonymous26-Jul-02 8:40
Anonymous26-Jul-02 8:40 
AnswerRe: How to kill a thread from DllMain Pin
Nemanja Trifunovic26-Jul-02 8:46
Nemanja Trifunovic26-Jul-02 8:46 
GeneralRe: How to kill a thread from DllMain Pin
Rama Krishna Vavilala26-Jul-02 8:47
Rama Krishna Vavilala26-Jul-02 8:47 
GeneralRe: How to kill a thread from DllMain Pin
Nemanja Trifunovic26-Jul-02 8:57
Nemanja Trifunovic26-Jul-02 8:57 
GeneralRe: How to kill a thread from DllMain Pin
Rama Krishna Vavilala26-Jul-02 9:02
Rama Krishna Vavilala26-Jul-02 9:02 
GeneralRe: How to kill a thread from DllMain Pin
Nemanja Trifunovic26-Jul-02 9:42
Nemanja Trifunovic26-Jul-02 9:42 
GeneralRe: How to kill a thread from DllMain Pin
Rama Krishna Vavilala26-Jul-02 9:51
Rama Krishna Vavilala26-Jul-02 9:51 
GeneralRe: How to kill a thread from DllMain Pin
Nemanja Trifunovic26-Jul-02 10:11
Nemanja Trifunovic26-Jul-02 10:11 
GeneralRe: How to kill a thread from DllMain Pin
Daniel Lohmann27-Jul-02 7:06
Daniel Lohmann27-Jul-02 7:06 
GeneralRe: How to kill a thread from DllMain Pin
Nemanja Trifunovic27-Jul-02 17:49
Nemanja Trifunovic27-Jul-02 17:49 
GeneralRe: How to kill a thread from DllMain Pin
Daniel Lohmann28-Jul-02 12:12
Daniel Lohmann28-Jul-02 12:12 
Generalfailed to create empty document!!! Pin
nss26-Jul-02 8:24
nss26-Jul-02 8:24 
GeneralRe: failed to create empty document!!! Pin
Anonymous26-Jul-02 8:33
Anonymous26-Jul-02 8:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.