?
Solved

Change Bitmap size

Posted on 2008-06-23
4
Medium Priority
?
2,545 Views
Last Modified: 2011-09-20
Hello all,

I have created a bitmap and would like to change it's pixel size dimensions to 640x200
before I save it.
How would I do that?

Here is my code:

Dim screenshot As Bitmap = CType(data.GetData(GetType(System.Drawing.Bitmap)), Bitmap)
'Here the conversion should happen.
screenshot.Save("C:\" & imagename & ".jpg")

Also, could you please tell me how does the size in kb changes?

Thanks!
0
Comment
Question by:nectarios777
[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
4 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 21850367
>>How would I do that?

Like this....

        Dim bmp As New Bitmap(640, 200)
        Dim g As Graphics = Graphics.FromImage(bmp)
        g.DrawImage(screenshot, 0, 0, bmp.Width, bmp.Height)
        bmp.Save("C:\" & imagename & ".jpg")

>>Also, could you please tell me how does the size in kb changes?

Making the image bigger increases the size (in kb), making it smaller decreases the size.

Wayne
0
 
LVL 1

Author Closing Comment

by:nectarios777
ID: 31469929
Many thanks!
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 21850973
* Just a side note...you are NOT creating a JPEG with your code!

What you have done in this line:

    bmp.Save("C:\" & imagename & ".jpg")

...is create a Bitmap with a .jpg extension.

To write as a JPEG, use the second parameter of Save():

    bmp.Save("C:\" & imagename & ".jpg", Imaging.ImageFormat.Jpeg)
0
 
LVL 1

Author Comment

by:nectarios777
ID: 21851036
Oh, I see.

Thanks.
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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

777 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