如何将视图另存为磁盘上的文件? [英] how to save a view as a file on the disk ?

查看:104
本文介绍了如何将视图另存为磁盘上的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
实际上,我正在开发一种画笔类型的应用程序,在该应用程序中我需要对图像进行少量编辑,现在我必须将其保存到磁盘上.现在我应该如何进行?

Hi to all ,
actually i am developing a paint brush type App where i need to do few editing on the image and now I have to save it to the disk . Now how should I proceed ?

推荐答案

如果您具有窗口的设备上下文(例如在OnPaint处理程序内部),即dc:

If you have the device context of the window (for instance inside the OnPaint handler), namely dc:

CDC dcMem;
CBitmap bmp;
CRect rc;
CImage img;

dcMem.CreateCompatibleDC(&dc);
GetWindowRect(&rc);
bmp.CreateCompatibleBitmap( &dcMem, rc.Width(), rc.Height());
dcMem.SelectObject(&bmp);
dcMem.BitBlt(0,0,rc.Width(), rc.Height(), &dc, 0,0, SRCCOPY);

img.Attach(bmp);
img.Save(_T("MyBitmap.bmp"), Gdiplus::ImageFormatBMP);


你好

尝试更换
img.Attach(bmp);

img.Attach(((HBITMAP)(bmp-> GetSafeHandle()));

杰克
hello

try to replace
img.Attach(bmp);
by
img.Attach((HBITMAP)(bmp->GetSafeHandle()));

Jack


您应该继续工作...:rolleyes:

认真地说,您应该告诉我们更多的事情...如果您已经在开发像这样的应用程序,则应该告诉我们您已经取得了什么成就,您在哪里陷入困境...

为了将映像存储到磁盘,您应该知道以下事实:每种映像格式都有其自己的存储方式.因此,首先您应该确定目标格式,因此应该确定要使用哪种格式...

之后,您将必须控制鼠标事件,移动和按钮,以便能够绘制...

然后,您将需要绘制到屏幕中并能够捕获您在内存中绘制的图形,以便能够将其存储到磁盘(使用正确的格式).

根据编辑情况,您将需要大量数学运算才能进行...但是...

好吧...告诉我们有关该项目的更多信息...您遇到了哪些问题...
You should continue working... :rolleyes:

Seriously, you should tell us more things... if you are already working on an app like that one you should tell us what you''ve achieved, where are you stuck...

In order to store images to disk you should be aware of the fact that each image format has its own way to be stored. So first of all you should decide the target format and therefore you should decide which format do you want to use...

After that you will have to control the mouse events, movements and buttons in order to be able to draw...

Then you will be in the need of drawing into the screen and being able to capture the drawing you''ve made in memory in order to be able to store it to disk (using the right format).

Depending on the editing you will need a lot of maths to proceed... but...

well... tell us more about the project... which problems you have...


这篇关于如何将视图另存为磁盘上的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆