Drawing Graphs using GDI
-
6. března 2012 11:23
I am trying to create a similar kind of graph in the below mentioned image .
I have managed to create the something similar to that. But now I want to implement Scaling. How can implement exact sales to fit those 2 points?
Adeel
Všechny reakce
-
6. března 2012 12:33
I think you could draw your 3 colored zone in a memory buffer and associated this buffer to graphical Interface thanks to CreateDIBSection, add texts around your graphe .
To implement Scaling use the StretchBlt function to resize the image and add units texts around your graph with adpated scale to good repositionning it.
Delphine GARRO
- Navržen jako odpověď GARRO Delphine 26. března 2012 15:46
- Označen jako odpověď Jesse JiangMicrosoft Contingent Staff, Moderator 28. března 2012 7:32
-
12. března 2012 12:18Thanks can you show me an example where StretchBlt is used to create Scales?
Adeel
-
12. března 2012 12:26
HDC hDisplayObject; hDisplayObject = CreateCompatibleDC( NULL); SelectObject( hDisplayObject, HandleFullDraw ); ::StretchBlt(Context, x_OnScreen, y_OnScreen, NewWidth,NewHeight,hDisplayObject, 0, 0, RealWidth,RealHeight, SRCCOPY ); DeleteDC( hDisplayObject );
Delphine GARRO
-
12. března 2012 12:56
HDC hDisplayObject; hDisplayObject = CreateCompatibleDC( NULL); SelectObject( hDisplayObject, HandleFullDraw ); ::StretchBlt(Context, x_OnScreen, y_OnScreen, NewWidth,NewHeight,hDisplayObject, 0, 0, RealWidth,RealHeight, SRCCOPY ); DeleteDC( hDisplayObject );
Delphine GARRO
Thanks what is HandleFullDraw in this case?Adeel
-
12. března 2012 14:41
#define BYTES_PER_PIXEL_VIDEO 4 HDC hdc; int NbPixels, L, H; DWORD *CouleurImage, CouleurDeFond; BITMAPINFO EnteteBitmap;// bitmap header HANDLE HandleFullDraw; VOID *ptrPixelImageGRAPHE; L=1024; H=600; NbPixels= L*H; hdc = CreateCompatibleDC(NULL); ZeroMemory(&EnteteBitmap, sizeof(BITMAPINFO)); EnteteBitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); EnteteBitmap.bmiHeader.biWidth = L; EnteteBitmap.bmiHeader.biHeight = -H; EnteteBitmap.bmiHeader.biPlanes = 1; EnteteBitmap.bmiHeader.biBitCount = 8*BYTES_PER_PIXEL_VIDEO; EnteteBitmap.bmiHeader.biCompression = BI_RGB; /*32bits par couleurs: 24 bits pour RGB, 8bits pour transparence*/; EnteteBitmap.bmiHeader.biSizeImage = NbPixels * BYTES_PER_PIXEL_VIDEO; // create our DIB section and select the bitmap into the dc HandleFullDraw = CreateDIBSection(hdc, &EnteteBitmap, DIB_RGB_COLORS, ptrPixelImageGRAPHE, NULL, 0x0); CouleurImage=(DWORD*)ptrPixelImageGRAPHE; // Backplane of graph until StrechBlt //Modify firt pixel red: CouleurImage[0]=RGB( 255,0,0);Delphine GARRO
-
12. března 2012 22:57
This isn't really an answer, but an observation. If you plan to do anything fancy along the way you may save yourself a lot of grief using a package that already does what you want. There are lots of them, but one for MFC is from Codejock...
You can do a lot of really nice charting and I think the price is around $200 (not too much programmer time to make that up).
I don't work for Codejock. Just a customer
:o)
Tom
-
28. března 2012 7:33Moderátor
Hi Adeel,
I marked Delphine's reply as answer, if your issue have not been solved please unmark it and update more information about this issue.
Best regards,
Jesse
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us