我需要在应用程序中实现作物 [英] I need to implement crop in my application

查看:89
本文介绍了我需要在应用程序中实现作物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问有人可以帮我吗?
我正在使用 queens_imageControl 作者:Anthony Queen
文章:平移和缩放非常大的图像
具有平移缩放和窗口缩放功能.

我需要在其中实现作物功能,但我无法做到.

我所做的是:-在DrawingBorad控件上

我创建了一个cropImage()函数,它带有两个参数

ie.cropImage(img,cropArea)和函数返回图像的裁剪部分(即bmpCrop),我将其作为图像类型的变量(即m_cropedImage)放在绘图板控件的mouseUpevent上.

image是a:-类型为system.drawing.Image
的图像 cropArea是一个:-从矩形绘制的区域.


QueensImageControl:-它是图像查看器

在mouseUp_event上,我正在调用裁剪函数ie.cropImage(m_OriginalImage,m_Select_Rect)并将裁剪后的图像保存在cropImage()函数返回的变量(ie.m_cropedImage)中

然后我在QueensImage控件中创建了一个方法ropp(),在其中我将变量(即,m_cropedImage)的值显示到drawingBoard

在我应用程序的主要形式中,我调用了裁剪方法

但在运行时,它不会在图像控件中显示裁剪的图像
我不知道怎么了

我的代码是:-

please Can Any one help me!
i am using queens_imageControl Author:Anthony Queen,
Article:Pan and Zoom Very Large Images
which has a feature pan zoom and window zoom.

I need to implement crop feature in it but i am not able to do it.

what i did is :-On DrawingBorad control

i created a cropImage()function which take two params

ie.cropImage(img,cropArea)and function returns cropped portion of image(ie.bmpCrop) which i take it in variable of type image ie.m_cropedImage on mouseUpevent of drawingboard control.

image is a:- image of type system.drawing.Image
cropArea is a:-area drawn from a rectangle.


QueensImageControl :-it is image viewer

on mouseUp_event i am calling crop function ie.cropImage(m_OriginalImage, m_Select_Rect)and holding cropped image in variable(ie.m_cropedImage) returned by cropImage()function

then i created a method crop()in QueensImage control in which i am displaying the value of variable(ie.m_cropedImage)to drawingBoard

and in my main form of my application i am calling the crop method

but on run time it doesnot display the croppedimage in the image control
i dont know what is going wrong

My code is:-

OnDrawingboard Control
 
Public Function cropImage(ByVal img As Image, ByVal cropArea As Rectangle) As Image
        Dim bmpImage As New Bitmap(img)
        Dim bmpCrop As Bitmap = bmpImage.Clone(cropArea, bmpImage.PixelFormat)
        Return DirectCast(bmpCrop, Image)
    End Function




绘图板控件的OnMouseUp_event




OnMouseUp_event of Drawingboard Control

Public Sub DrawingBoard_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
        If m_OriginalImage Is Nothing Then Exit Sub
        If Not PanMode Then
            EndPoint = New Point(e.X, e.Y)
            If Selected_Rectangle = Nothing Then Exit Sub
            m_cropedImage = cropImage(m_OriginalImage, m_Select_Rect)
            ''ZoomSelection()
        End If
    End Sub



在Queens_ImageControl上



On Queens_ImageControl

Public Sub crop()
        Dim crp As DrawingBoard = New DrawingBoard()
        Me.DrawingBoard1.Image = crp.m_cropedImage
        Me.Invalidate()
    End Sub



关于我的申请表的主要形式



On main form of my application

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Me.ImageControl1.crop()      
    End Sub



[edit]标记已从C#更改为VB-OriginalGriff [/edit]



[edit]Tags changed from C# to VB - OriginalGriff[/edit]

推荐答案

尝试此
具有裁剪和调整大小功能,同时保持宽高比的简单图像编辑器 [
try this
Simple Image Editor with Crop and Resize while Maintaining Aspect Ratio[^]

use reflector to convert vb.net


这篇关于我需要在应用程序中实现作物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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