Solved

Change Bitmap size

Posted on 2008-06-23
4
2,526 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to add field in my script 2 24
Vb.Net Menu 1 22
Deserialize JSON array VB.Net problem 3 38
Spacing between controls 4 17
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now