Solved

Help scale up an image without distorting it.

Posted on 2007-11-27
4
2,155 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

856 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