用C语言设计 切记不要用c++ 初等函数曲线图形的简易绘制:设屏幕显示文本是25行,80列,可以用

用C语言设计 切记不要用c++
初等函数曲线图形的简易绘制:设屏幕显示文本是25行,80列,可以用“+”和“——〉”
号画坐标系,用“*”号画曲线上的点。用户给出初等函数,如cos(x),ex,x
3-3x+1等,
及x的取值范围,程序绘制出对应初等函数的曲线图。
【功能要求】
1.从键盘上输入x的显示范围;
2.根据x的取值范围在屏幕上画出函数图形;
3.函数的选择可以由键盘输入得到

可以 CDC * pDC = pWnd->GetDC();
然后直接调用 CDC的成员函数实现曲线的绘制,具体看看msdn,上面有详细的说明,对于你所说的函数曲线直线片段来实现,使用for循环,递增t的值得到y的值。
打开位图BMP,使用 LoadImage 函数,MSDN上有说明,指定相应的参数即可,注意指定 LR_LOADFROMFILE 参数,返回值是图形的句柄,然后通过CDC的函数BitBlt来在设备描述符上绘制图象,
CBitmap bmp;
if (bmp.LoadBitmap(IDB_BITMAP1))
{
// Get the size of the bitmap
BITMAP bmpInfo;
bmp.GetBitmap(&bmpInfo);

// Create an in-memory DC compatible with the
// display DC we're using to paint
CDC dcMemory;
dcMemory.CreateCompatibleDC(pDC);

// Select the bitmap into the in-memory DC
CBitmap* pOldBitmap = dcMemory.SelectObject(&bmp);

// Find a centerpoint for the bitmap in the client area
CRect rect;
GetClientRect(&rect);
int nX = rect.left + (rect.Width() - bmpInfo.bmWidth) / 2;
int nY = rect.top + (rect.Height() - bmpInfo.bmHeight) / 2;

// Copy the bits from the in-memory DC into the on-
// screen DC to actually do the painting. Use the centerpoint
// we computed for the target offset.
pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,
0, 0, SRCCOPY);

dcMemory.SelectObject(pOldBitmap);
}
}
这段MSDN上的代码你参考一下 忘采纳!!追问

我只会初级的C语言程序设计 这么深奥看不懂(#-.-)

追答

您好,这已经很详细,易懂了,建议逐句理解。c语言学习非一蹴而就,要因难而上。望采纳!!

温馨提示:答案为网友推荐,仅供参考
相似回答