visual c++图形处理问题

来源:百度知道 编辑:UC知道 时间:2024/05/29 01:02:45
刚准备学visual c++6.0就接到两道习题,时间很紧,想先在此请教众大虾解燃眉之急了,拜谢各位老师了!!
1.在MFC环境下,完成一个画函数曲线y=Asin(ωt+φ)的程序,并可以修改A,ω,φ的值.

2.用程序打开一个位图文件.(1)在界面上显示图像 (2)改变其颜色 (3)旋转

粗略看了看书,感觉这两题应该来说算vc图形处理中比较初等的问题,可时间真是很紧迫,现学估计来不及,所以希望大侠们不吝赐教啊,小生再拜谢了.^^

取窗口的DC,比如你要在某个 CWnd窗口下绘图
可以 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.bmHei