Solved

Change Bitmap size

Posted on 2008-06-23
4
2,532 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
  • 2
4 Comments
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 125 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 85

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

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