Click here to Skip to main content
15,894,180 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany29-Jun-10 8:38
Alan Balkany29-Jun-10 8:38 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais29-Jun-10 8:47
humais29-Jun-10 8:47 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany29-Jun-10 9:45
Alan Balkany29-Jun-10 9:45 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais30-Jun-10 4:52
humais30-Jun-10 4:52 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany1-Jul-10 5:59
Alan Balkany1-Jul-10 5:59 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
humais1-Jul-10 19:38
humais1-Jul-10 19:38 
GeneralRe: How i can Save Cimage file+ shapes & text on it? Pin
Alan Balkany6-Jul-10 3:23
Alan Balkany6-Jul-10 3:23 
QuestionDrawing on 8bpp grayscale bitmap (unmanaged) Pin
Alan Balkany29-Jun-10 4:52
Alan Balkany29-Jun-10 4:52 
Hi all,

I've been attempting to draw on an 8bpp grayscale bitmap without success. Here are some of my attempts. Maybe someone can point out what I'm doing wrong.


===================================================
Attempt 1: Create, select, and draw:

In constructor:
CBitmap bm;
bm.CreateBitmap (200, 200, 1, 8, NULL);

In OnDraw:
CDC *mdc=new CDC ();
HGDIOBJ tmp = mdc->SelectObject(bm);

Result: tmp is NULL, indicating failure.


===================================================
Attempt 2: CreateDIBSection

In constructor:
HBITMAP hbm;
BITMAPINFOHEADER bih;
BITMAPINFO bi;
HANDLE hb;
CDC* myDc = new CDC ();
HDC hdc = myDc->GetSafeHdc ();
void* bits;
RGBQUAD rq [256];

	initBi ();
	hbm = CreateDIBSection (hdc, &bi, DIB_RGB_COLORS, &bits, NULL, 0);

...
void CEightBitDrawingView::initBi()
{
	bih.biSize = sizeof (BITMAPINFOHEADER);
	bih.biWidth = 200;
	bih.biHeight = -200;
	bih.biPlanes = 1;
	bih.biBitCount = 8;
	bih.biCompression = BI_RGB;
	bih.biSizeImage = 0;
	bih.biXPelsPerMeter = 14173;
	bih.biYPelsPerMeter = 14173;
	bih.biClrUsed = 0;
	bih.biClrImportant = 0;

	memset ((void *) rq, 0, 256 * sizeof (RGBQUAD));

	bi.bmiHeader = bih;
	bi.bmiColors = rq;
}


Result: This doesn't even compile because the BITMAPINFO bmiColors member is defined as:
RGBQUAD          bmiColors[1];

so won't accept more than one RGB color. In fact, nothing I assign to this member compiles! (Could they possibly make it any more complex!?)

Any suggestions would be appreciated! Thanks!

===================================================
AnswerRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat29-Jun-10 5:46
Code-o-mat29-Jun-10 5:46 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Alan Balkany29-Jun-10 5:53
Alan Balkany29-Jun-10 5:53 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat29-Jun-10 6:07
Code-o-mat29-Jun-10 6:07 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Alan Balkany29-Jun-10 8:21
Alan Balkany29-Jun-10 8:21 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat29-Jun-10 9:37
Code-o-mat29-Jun-10 9:37 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat29-Jun-10 9:46
Code-o-mat29-Jun-10 9:46 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Alan Balkany29-Jun-10 9:47
Alan Balkany29-Jun-10 9:47 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat29-Jun-10 9:55
Code-o-mat29-Jun-10 9:55 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Alan Balkany1-Jul-10 4:50
Alan Balkany1-Jul-10 4:50 
GeneralRe: Drawing on 8bpp grayscale bitmap (unmanaged) Pin
Code-o-mat1-Jul-10 5:57
Code-o-mat1-Jul-10 5:57 
QuestionShaving a section from a dialog. Pin
Spawn@Melmac29-Jun-10 4:46
Spawn@Melmac29-Jun-10 4:46 
AnswerRe: Shaving a section from a dialog. Pin
Code-o-mat29-Jun-10 5:13
Code-o-mat29-Jun-10 5:13 
GeneralRe: Shaving a section from a dialog. Pin
David Crow29-Jun-10 5:32
David Crow29-Jun-10 5:32 
GeneralRe: Shaving a section from a dialog. Pin
Code-o-mat29-Jun-10 5:34
Code-o-mat29-Jun-10 5:34 
GeneralRe: Shaving a section from a dialog. Pin
Spawn@Melmac29-Jun-10 5:51
Spawn@Melmac29-Jun-10 5:51 
GeneralRe: Shaving a section from a dialog. Pin
Code-o-mat29-Jun-10 5:58
Code-o-mat29-Jun-10 5:58 
AnswerRe: Shaving a section from a dialog. Pin
David Crow29-Jun-10 5:37
David Crow29-Jun-10 5:37 

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.