473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

DrawImage problem (not retaining the pixel configuration)

Hello Guys,

Iam working on a zoom in and out tool and here is the code iam using for it
//Method for zooming in

Bitmap bmpSource=new Bitmap(ImgBox.Image);
Bitmap bmpZoomed=new
Bitmap(bmpSource.Width*ZoomInFactor,bmpSource.Heig ht*ZoomInFactor);

Graphics grZoom=Graphics.FromImage(bmpZoomed);
grZoom.InterpolationMode=InterpolationMode.HighQua lityBilinear;
grZoom.DrawImage(bmpSource,0,0,bmpZoomed.Width+1,b mpZoomed.Height+1);
ImgBox.Image=bmpZoomed;

//Method for zooming Out

Bitmap bmpSource=new Bitmap(ImgBox.Image);
Bitmap bmpZoomed=new
Bitmap(bmpSource.Width/ZoomInFactor,bmpSource.Height/ZoomInFactor);

Graphics grZoom=Graphics.FromImage(bmpZoomed);
grZoom.InterpolationMode=InterpolationMode.HighQua lityBilinear;
grZoom.DrawImage(bmpSource,0,0,bmpZoomed.Width+1,b mpZoomed.Height+1);
ImgBox.Image=bmpZoomed;

It is working fine but the picture resulution is lost if we do symultaneous
multiple zoomin and zoom out..Specially if you zoomout first and then zoom
in...
Any ideas on how to retain the pixel configuration ....
Any valuable thought should help

Cheerz,
Ajay
Nov 17 '05 #1
1 2024
The problem is that you are altering an image and storing in in an
ImageBox object and then using the same image to zoom out from.

Therefore these scaling operations are effecting the output image
quality which is then used as input.

It would be better to store a copy of the original bitmap somewhere in
your code and base the scaling operation on that copied image. I.e.
instead of

Bitmap bmpSource=new Bitmap(ImgBox.Image)

use the original copy

Bitmap bmpSource=this.mysavedcopy;

Andrew Murray

Ajay wrote:
Hello Guys,

Iam working on a zoom in and out tool and here is the code iam using for it
//Method for zooming in

Bitmap bmpSource=new Bitmap(ImgBox.Image);
Bitmap bmpZoomed=new
Bitmap(bmpSource.Width*ZoomInFactor,bmpSource.Heig ht*ZoomInFactor);

Graphics grZoom=Graphics.FromImage(bmpZoomed);
grZoom.InterpolationMode=InterpolationMode.HighQua lityBilinear;
grZoom.DrawImage(bmpSource,0,0,bmpZoomed.Width+1,b mpZoomed.Height+1);
ImgBox.Image=bmpZoomed;

//Method for zooming Out

Bitmap bmpSource=new Bitmap(ImgBox.Image);
Bitmap bmpZoomed=new
Bitmap(bmpSource.Width/ZoomInFactor,bmpSource.Height/ZoomInFactor);

Graphics grZoom=Graphics.FromImage(bmpZoomed);
grZoom.InterpolationMode=InterpolationMode.HighQua lityBilinear;
grZoom.DrawImage(bmpSource,0,0,bmpZoomed.Width+1,b mpZoomed.Height+1);
ImgBox.Image=bmpZoomed;

It is working fine but the picture resulution is lost if we do symultaneous
multiple zoomin and zoom out..Specially if you zoomout first and then zoom
in...
Any ideas on how to retain the pixel configuration ....
Any valuable thought should help

Cheerz,
Ajay

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jeroen Ceuppens | last post by:
Hi, When i do this in my programma, in the contstructor of the form: g.DrawImage(i,new Rectangle(0,0,i.Width,i.Height),0,0,i.Width,i.Height,GraphicsUnit.Pixel); it doens't paint it ;( but if...
1
by: Ivan | last post by:
Hi there I'm trying to use BitBlt function instead od DrawImage beacuse I need speed in my app. I have one Bitmap (bmp) that is loaded from file and I use it in OnPaint for drawing. Currently I...
2
by: krishnan | last post by:
Hi Guys My project is to dispaly the image in a usercontrol. and user will be able to scroll it. But when the image is too large (say width = 2592,Height=1952) the scrolling becomes slow.....
2
by: cFleury | last post by:
This system works in a intranet w/ some 200 stations and this particular form is retaining its values among different stations...like if I enter some values in the form on station 1 walk to station...
2
by: Chris Morse | last post by:
Hi, I'm trying to create a little program that loads a 1bpp bitmap (black/white) and displays it in a PictureBox using the PictureBox's Paint event. I have buttons for zooming in/out and I...
0
by: news | last post by:
Hi guys, Am I right in thinking that the DrawImage method will only render in 8bits/pixel ? I have the following code (assume my16bitImage is a 16bit bitmap in memory) .... myMatrix = new...
0
by: Jon Slaughter | last post by:
I'm manually displaying images in a TreeView but when I stick the images in the Images(icons) container in the TreeView and use DrawImage they look like crap but when I force an icon draw and use...
2
by: kirkage | last post by:
I am attempting to create a program in C# which part of it consists of one image fading to another. The best way I found this to work is from an example by Bob Powell on the thread...
8
by: Phil | last post by:
Is it possible to find the size of the MDIClient area, excluding the space already used by docked controls? I have thought I could perhaps create a new control, set it's Dock property to Fill and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.