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

C / C++ / MFC

 
AnswerRe: Smaller than a byte Pin
Sameerkumar Namdeo27-Sep-07 17:42
Sameerkumar Namdeo27-Sep-07 17:42 
QuestionRe: Smaller than a byte Pin
zakkas248327-Sep-07 23:49
zakkas248327-Sep-07 23:49 
AnswerRe: Smaller than a byte Pin
Iain Clarke, Warrior Programmer28-Sep-07 5:31
Iain Clarke, Warrior Programmer28-Sep-07 5:31 
QuestionNeed a best possible alternative?? Pin
Kiran Satish27-Sep-07 7:08
Kiran Satish27-Sep-07 7:08 
AnswerRe: Need a best possible alternative?? Pin
Mark Salsbery27-Sep-07 7:31
Mark Salsbery27-Sep-07 7:31 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish1-Oct-07 10:41
Kiran Satish1-Oct-07 10:41 
QuestionRe: Need a best possible alternative?? Pin
Mark Salsbery1-Oct-07 11:15
Mark Salsbery1-Oct-07 11:15 
AnswerRe: Need a best possible alternative?? Pin
Kiran Satish1-Oct-07 11:34
Kiran Satish1-Oct-07 11:34 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery1-Oct-07 11:53
Mark Salsbery1-Oct-07 11:53 
GeneralRe: Need a best possible alternative?? [modified] Pin
Kiran Satish2-Oct-07 5:40
Kiran Satish2-Oct-07 5:40 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 5:48
Mark Salsbery2-Oct-07 5:48 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 6:34
Mark Salsbery2-Oct-07 6:34 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 7:01
Mark Salsbery2-Oct-07 7:01 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 7:42
Kiran Satish2-Oct-07 7:42 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 8:13
Mark Salsbery2-Oct-07 8:13 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 8:21
Kiran Satish2-Oct-07 8:21 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 8:25
Mark Salsbery2-Oct-07 8:25 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 8:41
Kiran Satish2-Oct-07 8:41 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery2-Oct-07 9:11
Mark Salsbery2-Oct-07 9:11 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish2-Oct-07 9:45
Kiran Satish2-Oct-07 9:45 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish3-Oct-07 10:46
Kiran Satish3-Oct-07 10:46 
I found very little help on DIBSection while found many examples on using CBitmap class. Anyway I started off routine of my application where I color boxes in a window.

My window (with 12x12 grid) is 513x513 and the grid's horizontal and vertical offset is 20 (this would be the width of the border of the grid) and box width (each box in the grid) is 15 and box gap is 2(this would be the width of grid lines inside). These are constants and they stay the same all the time.

So while creating this window object I have to do the following--
LONG DIBSecWidth = 513;
LONG DIBSecHeight = 513;
LONG BitsPerPixel = 24;
CDC *ResCDC = ResDisp->GetDC();/*ResDisp is handle of this window and ResCDC need not be changed while redrawing so I dont need to call it everytime I call the above routine.*/
LONG Stride = ((DIBSecWidth * BitsPerPixel + 31L) & (~31L)) / 8L; /**I didnt understand this step, how can I calculate this in my case*/
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmi.bmiHeader.biWidth = DIBSecWidth;
bmi.bmiHeader.biHeight = DIBSecHeight;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biBitCount = (WORD)BitsPerPixel;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biSizeImage = Stride * abs(DIBSecHeight);
BYTE *pDIBSectionBits;

HBITMAP hbm = ::CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, (void**)&pDIBSectionBits, NULL, 0);/**I have to replace first argument NULL with my ResCDC */

From then I couldnt understand how I can find pixel address for each pixel in my application while considering box sizes and gap. D'Oh! | :doh:
Now I have to color each box with some color, so is there any way to fill each box in memory with that same color rather going in two for loops, like using fillrect etc?? This way I can eliminate the inner two for loops in my code.

thanks,

PKNT

GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery3-Oct-07 11:18
Mark Salsbery3-Oct-07 11:18 
GeneralRe: Need a best possible alternative?? [modified] Pin
Kiran Satish3-Oct-07 12:13
Kiran Satish3-Oct-07 12:13 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery3-Oct-07 12:49
Mark Salsbery3-Oct-07 12:49 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish8-Oct-07 15:17
Kiran Satish8-Oct-07 15:17 

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.