473,473 Members | 2,166 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Working on Images in Custom Controls with C#

2 New Member
Hi there,

I've been told to write a custom control using C#.NET ( 2.0 ).
This control should be able to display images and give access to zoom functionality. I've visited numerous How-To pages and the main stream approach appears to be a panel/groupBox containing a pictureBox, resizing that pictureBox and using the PictureBoxSizeMode.StretchImage property.
I don't want that. What I want is some "real" zoom effect. So I continued my search for good tutorials until I found this. After reading this small article I began working with the 'graphics' class which appeared to have everything I need. Now I can draw all kinds of manipulated images, which almost perfectly suites my needs. Only almost because I can only DRAW them where I would also need to SAVE them ... And this basically is my question. How do I manipulate images ( for example but not restricting to Bitmaps ), draw them AND save them afterwards ?
Actually saving these images is not my actual issue. My real problem is that I would like to use the PictureBox.SizeMode.AutoSize property inside my custom control so refitting the internal pictureBox is not such a huge pain. But since I am only drawing the modified image ( e.g. using Graphics.TranslateTransform before drawing ) and cannot actually save it, I have no chance to resize the picture box to the new image's size - the image's size always stays the sime ...

Amnu
Jun 27 '08 #1
1 2059
Amnu
2 New Member
Of Course ... Now that I've posted a question I've found a solution ...
Well, I've found this
and this:

public static Image ScaleImage(Image img, int outputWidth, int outputHeight)
{
Btmap outputImage = new Bitmap(outputWidth, outputHeight, img.PixelFormat);
outputImage.SetResolution(img.HorizontalResolution , img.VerticalResolution);
Graphics graphics = Graphics.FromImage(outputImage);
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.DrawImage(img, new Rectangle(0, 0, outputWidth, outputHeight),
new Rectangle(0, 0, img.Width, img.Height), GraphicsUnit.Pixel);
graphics.Dispose();
return outputImage;
}

solved my problem. It's about what I was looking for. The one thing bugging me now is a perfomance issue and some flickering.
If I apply the above code in my custom control and trigger the ScaleImage method, I do get the scaled image and I can display it in the picture box. But if I scroll through the scaled image flickering at the borders of the pictore box occurs. Why ? How do I solve this ?
Also, performance dropps super linear while increasing scaling factor. I suppose this is related to the increasing image's size but I don't know how to compensate for it. My only guess is changing the interpolation quality according to the image's size but that's not really an option...

Amnu
Jun 27 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rob | last post by:
Access Gurus, This script was used to view the reports on the web by choosing a date on or before the current day.Recently it stopped working and i am not able to figure where the problem is. ...
1
by: Rob | last post by:
Access Gurus, This script was used to view the reports on the web by choosing a date on or before the current day.Recently it stopped working and i am not able to figure where the problem is. ...
9
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be...
1
by: TonyB | last post by:
Hi, Repost of question in microsoft.public.vb.general.discussion as was pointed out vbdotnet is not same language as vb6. I'm new to vb.net and have a question re user interface.(Is there a better...
1
by: NightOwl888 | last post by:
I have an older web project that I am trying to update with new .NET 2.0 features. I put new master pages in a subdirectory below the project directory. This particular project runs under IIS...
0
by: Omer | last post by:
I am trying to create a shared addin using visual studio 2005 with the following code. It is working only in Power Point Appliction and not loading in Excel and Word I used the Visual Studio Wizard...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.