Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 740733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:33:00+00:00 2026-05-14T08:33:00+00:00

There is something I am missing. Say I have the following code: private Bitmap

  • 0

There is something I am missing. Say I have the following code:

private Bitmap source = new Bitmap (some_stream);
Bitmap bmp = new Bitmap(100,100);
Rectangle newRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
Rectangle toZoom= new Rectangle(0, 0, 10, 10);

Graphics g = Graphics.FromImage(bmp);
g.DrawImage(source, newRect, toZoom, GraphicsUnit.Pixel);

My goal is to zoom-in the 10×10 pixels on the top left corner of the source picture. After I created the graphics object g and called DrawImage: the requested rectangle (toZoom) will be copied to bmp, or will it be displayed on the screen? I am a bit confused, can somebody please clarify?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:33:00+00:00Added an answer on May 14, 2026 at 8:33 am

    You code will only give you an in-memory bitmap (which won’t automatically be displayed to the screen). A simple way to display this would be to put a 100 x 100 PictureBox on your form, and set its Image property like this (using the Bitmap from your code above):

    pictureBox1.Image = bmp;
    

    Also, you’ll want some using blocks in your code:

    using (private Bitmap source = new Bitmap (some_stream))
    {
        Bitmap bmp = new Bitmap(100,100);
        Rectangle newRect = new Rectangle(0, 0, bmp.Width, bmp.Height);
        Rectangle toZoom= new Rectangle(0, 0, 10, 10);
        using (Graphics g = Graphics.FromImage(bmp))
        {
            g.DrawImage(source, newRect, toZoom, GraphicsUnit.Pixel);
        }
        pictureBox1.Image = bmp;
    }
    

    Note that there is no using block with bmp – this is because you’re setting it as the PictureBox’s Image property. The using block automatically calls an object’s Dispose method at the end of the block’s scope, which you don’t want to do since it will still be in use.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a homework question, but I think there's something missing from it. It
Am I missing something or there really is no support for generic object type
I'm sure there's something obvious I'm missing here, but I know that popover controls
Maybe I am missing something, but is there a way to search inside some
Maybe I am missing something, but in symfony examples, in form submission action there's
Potentially embarrassing question, but there is obviously something I'm missing that I want/need to
Is there something new about row-level security in SQL Server 2012? In 2008 and
In the following example, say you have a model where supp is a factor
I'm relatively new to Django and OO, so I may be missing something obvious,
Lets say I've run the following code: var toType = function(obj){ return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase(); };

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.