CImage -- Can't get it working
-
I want to use CImage to save a dib as a jpg file. However, whenever I save it produces a black rectangle. Any suggestions? Here is my code: CImage img; int h = 292; int w = 248; // Create a dib section img.Create(w, h, 8); // Get a DC and draw in it (a red rectangle) HDC hdc = img.GetDC(); RECT r; r.top = r.left = 0; r.bottom = h; r.right = w; HBRUSH br = ::CreateSolidBrush(RGB(255,0,0)); ::FillRect(hdc, &r, br); // Release the DC img.ReleaseDC(); // now save the image img.Save("c:/temp/testimg.jpg", Gdiplus::ImageFormatJPEG); I get a black rectangle file with the correct dimensions. I am sure I am doing something dumb, but any help would be appreciated. TIA.
-
I want to use CImage to save a dib as a jpg file. However, whenever I save it produces a black rectangle. Any suggestions? Here is my code: CImage img; int h = 292; int w = 248; // Create a dib section img.Create(w, h, 8); // Get a DC and draw in it (a red rectangle) HDC hdc = img.GetDC(); RECT r; r.top = r.left = 0; r.bottom = h; r.right = w; HBRUSH br = ::CreateSolidBrush(RGB(255,0,0)); ::FillRect(hdc, &r, br); // Release the DC img.ReleaseDC(); // now save the image img.Save("c:/temp/testimg.jpg", Gdiplus::ImageFormatJPEG); I get a black rectangle file with the correct dimensions. I am sure I am doing something dumb, but any help would be appreciated. TIA.
If CImage is a GDI+ class ( I don't remember, but it looks like it, I thought it was just called Image ), then you need to select it into a Graphics object and draw on it there. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002