Solved

Help scale up an image without distorting it.

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

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

19 Experts available now in Live!

Get 1:1 Help Now