Solved

Help scale up an image without distorting it.

Posted on 2007-11-27
4
2,153 Views
Last Modified: 2010-04-21
Hi All.

I have a small bmp that i created. 4 pixels wide and 4 pixels high.  When i display it in a picture box i want to be able to actually see the pixels rather than just a dot on the screen so i say stretch.  The problem is that it smooths out the pixels and is not an exact representation of the image like i see in my image viewer.

Any ideas on how to display the exact 4x4 pixel image but say 100x100 so the top left pixel was copied actuall 25x25 pixels without coding it myself?  

Thanks
0
Comment
Question by:asiminator
  • 2
4 Comments
 
LVL 7

Expert Comment

by:tcicatelli
ID: 20357486
A 4x4 bmp only has 16 pixels of information.  You can't expect to be able to stretch it to 100x100 (10,000 pixels) and maintain the same look.  Why don't you just recreate the bmp in the larger size?
0
 

Author Comment

by:asiminator
ID: 20357587
im not sure you understand.  im only interested in 16 pixels.  I just want a zoom function like a have in gimp or picture viewer or paint or any other tool that lets you look at each pixel in a expanded view
0
 
LVL 43

Accepted Solution

by:
Chris Stanyon earned 125 total points
ID: 20357829
You need to set the interpolation mode of the image, which I think you can only do in code. There doesn't seem to be a property for this in the designer.

In the paint event of the PictureBox add the following

        Dim PicWidth As Integer = 100
        Dim PicHeight As Integer = 100
        e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor
        e.Graphics.DrawImage(New Bitmap(Me.PictureBox1.Image), New RectangleF(0, 0, PicWidth, PicHeight))

This will 'zoom' into your image, rather than resizing it.

0
 

Author Closing Comment

by:asiminator
ID: 31411178
the zoom seems to crop the left and the top of the image by about 10 pixels.  Not sure why...
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Get hold of longitude and latitude in iframe string 11 46
VB.Net WebRequest Code from JSON curl 9 16
VB.net and sql server 4 36
C# LINQ ForEach() question 6 28
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

821 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