Click here to Skip to main content
15,886,963 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery9-Oct-07 6:00
Mark Salsbery9-Oct-07 6:00 
GeneralRe: Need a best possible alternative?? [modified] Pin
Kiran Satish9-Oct-07 6:10
Kiran Satish9-Oct-07 6:10 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery9-Oct-07 8:01
Mark Salsbery9-Oct-07 8:01 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish9-Oct-07 10:49
Kiran Satish9-Oct-07 10:49 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery10-Oct-07 5:24
Mark Salsbery10-Oct-07 5:24 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish10-Oct-07 6:56
Kiran Satish10-Oct-07 6:56 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish11-Oct-07 5:14
Kiran Satish11-Oct-07 5:14 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery11-Oct-07 5:30
Mark Salsbery11-Oct-07 5:30 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish11-Oct-07 12:53
Kiran Satish11-Oct-07 12:53 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery11-Oct-07 13:06
Mark Salsbery11-Oct-07 13:06 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish11-Oct-07 13:31
Kiran Satish11-Oct-07 13:31 
GeneralRe: Need a best possible alternative?? Pin
Mark Salsbery11-Oct-07 13:41
Mark Salsbery11-Oct-07 13:41 
GeneralRe: Need a best possible alternative?? Pin
Kiran Satish11-Oct-07 13:46
Kiran Satish11-Oct-07 13:46 

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.