Aurigma Forums
 » 
Graphics Mill
 » 
Discussions – Graphics Mill
 » 
Prefixed Proportional Rubberband VB.NET application
 
		
        
            
            
	
    | 
Rank: Newbie
 Groups: Guest
Joined: 8/2/2009(UTC)
 Posts: 2
 
 | 
            
	      
                Hi, I have downloaded the samples for VB.NET applications and I cannot work out how I would make the selection tool, rubberband a fixed ratio. The theory is that I only need 4 sizes, for a standard crop I would want 4|6 which would be saved @ 400 x 600 96ppi for articles, blogging or webuse. The web PhotoEditor already has the options of pre-setting the ratios in the xml, the user can then select an area and then crop, this is what I need for a desktop application, where the user opens an image, prepares and crops to pre-defined sizes on thier PC, when saved is at the pre-set set size and resolution,  and then the user uploads the images to their blog at web size and quality or uses them in an article. David     Edited by user Sunday, August 2, 2009 2:09:01 AM(UTC)
 | Reason: Not specified | 
	
    | 
             | 
            
         | 
    |  | 
        
        
        
         
		   
        
            
            
	
    | 
Rank: Advanced Member
 Groups: Guest
Joined: 3/9/2008(UTC)
 Posts: 554
 
 Was thanked: 1 time(s) in 1 post(s)
 | 
            
	      
                Hello David, I hope the following code helps you: Code:Private rect As Aurigma.GraphicsMill.WinControls.RectangleRubberband
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        BitmapViewer1.Bitmap = New Aurigma.GraphicsMill.Bitmap("c:/test.jpg")
        rect = New Aurigma.GraphicsMill.WinControls.RectangleRubberband()
        rect.Rectangle = New System.Drawing.Rectangle(BitmapViewer1.Bitmap.Width / 4, BitmapViewer1.Bitmap.Height / 4, 400, 600)
        rect.Ratio = 2 / 3
        rect.ResizeMode = Aurigma.GraphicsMill.WinControls.ResizeMode.Proportional
        BitmapViewer1.Rubberband = rect
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        BitmapViewer1.Bitmap.Transforms.Crop(rect.Rectangle)
    End Sub
 | 
|  | 
	
    | 
             | 
            
         | 
    |  | 
        
        
        
    
		
        
            
            
	
    | 
Rank: Newbie
 Groups: Guest
Joined: 8/2/2009(UTC)
 Posts: 2
 
 | 
            
	      
                Hi Tamila, I am only working with the Main Example for one day, so your answer is beyond my skills for now, but I have resolved it by creating two variables, a sub and a few lines of code. The theory for use is that for web blogs, articles and templates, there is no need for big hi-resolution images that can be stolen and upsized. Private cropWidth As Integer Private cropHeight As Integer I used code from the main examples and here is how I done it Code:
Private Sub InitializeForm()   
  <...
  >...
  ' Added lines to standard code
  ' Default to Portrait
  cropWidth = 400
  cropHeight = 600
 <...
  >...
End Sub 
Private Sub SetCropRatio(ByVal width As Integer, ByVal height As Integer)
        cropWidth = width
        cropHeight = height
        bitmapViewerMainView.Rubberband = rectangleRubberbandExample
        bitmapViewerMainView.Navigator = Nothing
        rectangleRubberbandExample.Ratio = cropWidth / cropHeight
        UnpushToolBarButtons()
        CropToolStripMenuItem.Enabled = (rectangleRubberbandExample.Rectangle.Width > 0) AndAlso (rectangleRubberbandExample.Rectangle.Height > 0)
End Sub
Private Sub cmdCrop1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCrop1.Click
   'Portrait      
   SetCropRatio(400, 600)
End Sub
Private Sub cmdCrop2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop2.Click
   'Landscape        
   SetCropRatio(600, 400)
End Sub
Private Sub cmdCrop3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop3.Click
   ' Square        
   SetCropRatio(600, 600)
End Sub
Private Sub cmdCrop4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop4.Click
   'Letterbox     
   SetCropRatio(600, 300)
End Sub
Private Sub cmdCrop5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop5.Click
   'Panoramic 
   SetCropRatio(800, 300)
End Sub
Private Sub cmdCrop6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop6.Click
  'Blog Page Header
   SetCropRatio(800, 200)
End Sub
Private Sub cmdCrop7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCrop7.Click
    'Crop from example and new call to Resize        
    If (rectangleRubberbandExample.Rectangle.Width > 0) AndAlso _
        (rectangleRubberbandExample.Rectangle.Height > 0) Then
            Dim cropRectangle As Rectangle = rectangleRubberbandExample.Rectangle
            
            rectangleRubberbandExample.Rectangle = New Rectangle(0, 0, _
            rectangleRubberbandExample.Rectangle.Width, _
            rectangleRubberbandExample.Rectangle.Height)
            ApplyTransform(New Crop(cropRectangle))
            'New code to resize
            ApplyTransform(New Resize(cropWidth, cropHeight, InterpolationMode.MediumQuality))
        End If
End Sub
 Regards David (it looks very much like I will be making a purchase in two weeks going by my initial testing) | 
	
    | 
             | 
            
         | 
    |  | 
        
        
        
    
Aurigma Forums
 » 
Graphics Mill
 » 
Discussions – Graphics Mill
 » 
Prefixed Proportional Rubberband VB.NET application
 
    
        Forum Jump
         
    
    You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.