Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Change Bitmap size

Posted on 2008-06-23
4
Medium Priority
?
2,549 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 48

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

598 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