使用delphi缩放图像
我正在与德尔福合作。我有 TImage,我为其分配了一个位图。
imgmain.Picture.Bitmap := bmpMain;
imgmain.Picture.Bitmap.PixelFormat := pf24bit;
imgmain 是 TImage 的对象,bmpMain 是 TBitmap 的对象
我想缩放图像。我的表单上有一个轨迹栏,当我单击轨迹栏时,图像应该会缩放。我该怎么办?
谢谢。
编辑:
我在此处找到了一些解决方案,它有效,但它削弱了我的形象。
I am working with delphi. I have TImage, to which I assign a bitmap.
imgmain.Picture.Bitmap := bmpMain;
imgmain.Picture.Bitmap.PixelFormat := pf24bit;
imgmain is object of TImage and bmpMain is object of TBitmap
I want to zoom my image. I have one trackbar on my form and as I click on trackbar the image should get zoom. What should I do?
Thank You.
Edit :
I found some solution at here It works but it cut my image.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您引用的代码设置了从一个坐标空间到另一个坐标空间的转换,我没有注意到任何会在那里剪切/裁剪您的图像的东西。然而,我宁愿使用易于理解的线性缩放,而不是成反比的缩放系数。另外,我认为没有理由根据比例因子切换地图模式,我会像这样修改
SetCanvasZoomFactor
;一个简化的(无错误检查)工作示例,其中将位图加载到 TImage,通过 TrackBar 进行缩放,如下所示。请注意,上述函数内联在 TrackBar 的 OnChange 事件中。
edit: same code with a TImage in a ScrollBox;
The code you refer to sets up a transformation from one coordinate space to another, I didn't notice anything that would cut/crop your image there. However, instead of having an inversely proportional zoom factor I'd rather have, easy to understand, linear scaling. Also, I see no reason switching map modes depending on the scaling factor, I would modify the
SetCanvasZoomFactor
like this;A simplified (no error checking) working example with a bitmap loaded to a TImage, scaled via a TrackBar could be like the below. Note that the above function is inlined in the TrackBar's OnChange event.
edit: same code with a TImage in a ScrollBox;