如何使用C ++中的drawimage图形在屏幕上绘制具有原始高度和宽度的原始图像而不使用宽度和高度进行拼接? [英] How to draw original image with its original height and width without chainging width and height on screen using drawimage graphics in C++?

查看:132
本文介绍了如何使用C ++中的drawimage图形在屏幕上绘制具有原始高度和宽度的原始图像而不使用宽度和高度进行拼接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我能够使用Draw Image()显示图像,但是在所有Microsoft网站上,他们都调整了矩形。因此,我只能显示图像的上半部分。我希望在不改变其高度或宽度的情况下显示完整的图像。这是我尝试过的所有但不起作用。只显示图像的上半部分:

picture = Image :: From File(image 9。 jpeg);



e-> Graphics-> Draw Image(图片,0,0); //仅显示图像的上半部分



我甚至试过这个:

e-> Graphics-> Draw Image(new Image ,x,y,宽度,高度);



我也尝试使用绘图rectagle:

R d = R(100,25,450,150) ;

R s = R(30,30,150,150); * /

图形`在这里输入代码`单位=图形单位::像素;

e-> Graphics-> DrawImage(图片,d,s,单位);



但是我想显示完整的图像而不仅仅是上半部分图片?



我尝试了什么:



我甚至试过这个:

e->图形 - >绘制图像(新图像,x,y,宽度,高度);



我也是尝试使用绘图rectagle:

R d = R(100,25,450,150);

R s = R(30,30,150,150); * /

图形`在这里输入代码`单位=图形单位::像素;

e->图形 - > DrawImage(图片,d,s,单位);



我叫这个从我的toolTip Draw_event处理程序使用它我想要将图像背景设置为我的toolTip控件按钮。

但我想显示完整的图像,而不仅仅是图像的上半部分?

解决方案

如果您的屏幕(或窗口)不够大,无法以原始大小显示完整图像,则无法进行此操作。



您可以调整图像大小以适应可用区域,或使用可滚动视图,用户可以在其中移动图像的可见部分。



用于调整大小可视区域的宽度和高度,并使用与图像大小差异较大的区域。然后用相同的因子缩放另一个维度。这样可以确保图像在两个维度上按相同因子缩放(缩放图像不在一个维度上压缩)。





我忘记了另一个选项:

从文件加载图像时,使用图像编辑器应用程序编辑并调整大小到所需的大小。

[/ EDIT]

最常见的情况是在加载后调整图像大小以适合您的绘图区域。使用最小因子缩放两个轴以固定纵横比。另一个最常用的场景是,你使用一个可滚动的控件,只显示部分。



提示:添加一个按钮(或双重clicke事件)来显示在新窗口中以完整尺寸显示图片。


I am able to show image using Draw Image() but on all Microsoft sites they have resize rectangle.Because of this i am able to show only upper part of image. I want to show full image without changing its height or width.This is all i tried but not working.Only upper part of image getting showed:
picture = Image::From File("image 9.jpeg");

e->Graphics->Draw Image(picture,0,0); //showing only upper part of image

I tried even this:
e->Graphics->Draw Image( new Image, x, y, width, height );

I also tried using drawing rectagle:
R d = R(100,25,450,150);
R s = R(30,30,150,150);*/
Graphics `enter code here`Unit units = Graphics Unit::Pixel;
e->Graphics->DrawImage(picture, d, s, units);

But i want to show full image and not only upper part of image?

What I have tried:

I tried even this:
e->Graphics->Draw Image( new Image, x, y, width, height );

I also tried using drawing rectagle:
R d = R(100,25,450,150);
R s = R(30,30,150,150);*/
Graphics `enter code here`Unit units = Graphics Unit::Pixel;
e->Graphics->DrawImage(picture, d, s, units);

I am calling this from my toolTip Draw_event handler using which i want to set image background to my toolTip control on button.
But i want to show full image and not only upper part of image?

解决方案

This is not possible if your screen (or window) is not large enough to show the complete image in its original size.

You can resize the image the image to fit in the available area or use a scrollable view where the user can move the visible part of the image.

For resizing get the width and height of the viewable area and use the one with the larger difference to the image size. Then scale the other dimension by the same factor. This ensures that the image is scaled by the same factor in both dimensions (scaled image not compressed in one dimension).

[EDIT]
I forgot another option:
When loading the image from file, edit and resize it to the required size using an image editor application.
[/EDIT]


Most common scenario is that you resize the image after loading to fit into your drawing area. Scale both axes with the smallest factor to pin the aspect ratio. The other most used scenario is that, you use a control which is scrollable and shows only parts.

Tip: add a button (or double clicke event) to show the picture in full size in a new windows.


这篇关于如何使用C ++中的drawimage图形在屏幕上绘制具有原始高度和宽度的原始图像而不使用宽度和高度进行拼接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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