?
Solved

Cropping Image to Make Thumbnail Using Rectangle Object

Posted on 2009-05-19
4
Medium Priority
?
362 Views
Last Modified: 2013-11-26
I am writing a program to manage an online image gallery and would like to include thumbnail creation.

I would like the user to be able to select a region of a JPG by dragging a 100 x 100 pixel rectangle object around within a picturebox.

I would then like to be able to take the area of the image that lies within the bounds of the rectangle and save it as its own JPG.

I've not done any work with image manipulation in VB before, and I am just looking for input or advice on making this happen. It seems like it should be easy enough, but I don't know where to start.
 
Thanks!
0
Comment
Question by:Sceler85
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 24427356
What version VB.net you working with?

What size are the source images?  Do they need to be able to see the whole thing at once?...or should it be scrollable?

Is the rectangle sizeable?...anything UP TO 100x100?...or should it be FIXED at 100x100?
0
 
LVL 1

Author Comment

by:Sceler85
ID: 24433206
I'm working with VB 2008.

Source Images will be around 800 X 600. I'm really looking to support variable dimensions over 100 X 100.

The 100 X 100 size is fixed. Ideally, I would like to open an additional form displaying the whole image, and allow the user to move around a rectangle to select the thumbnail. Thinking about it now, I can code the draggable rectangle pretty easily, so I really just need to know how to take the area of the JPG under the rectangle and convert it to it's own JPG.

I'm not completely opposed to defining the thumbnail by scrollbars as a last resort.
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 2000 total points
ID: 24433768
Ok...lemme know if you end up needing help implementing the actual selection part.

Once you have a "source" rectangle, you would just something like:
(assuming your source image is in PictureBox1)
        Dim sourceRC As New Rectangle(New Point(34, 101), New Size(100, 100))
        Dim bmp As New Bitmap(sourceRC.Width, sourceRC.Height)
        Dim G As Graphics = Graphics.FromImage(bmp)
        G.DrawImage(PictureBox1.Image, 0, 0, sourceRC, GraphicsUnit.Pixel)
        G.Dispose()
        bmp.Save("c:\someFile.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
 
        ' for demonstration purposes:
        PictureBox2.Image = bmp

Open in new window

0
 
LVL 1

Author Closing Comment

by:Sceler85
ID: 31583253
Awesome! Thanks for your help!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses
Course of the Month9 days, 23 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question