473,603 Members | 2,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Scaling performance problem

I have tried a few different methods for scaling an image down but all
seem a bit on the slow side. Is there any way i can make this scaling
faster.......
Here is how i do it now.
To display my image at 1:2 zoom i have the following
xScaleFactor = 0.5
yScaleFactor = 0.5
public static Bitmap ScaleBitmap(Bit map inputBmp, double xScaleFactor,
double yScaleFactor) {
//Create a new bitmap object based on the input
Bitmap newBmp = new Bitmap((int)(in putBmp.Size.Wid th*xScaleFactor ),
(int)(inputBmp. Size.Height*ySc aleFactor),
PixelFormat.For mat32bppArgb);//Graphics.FromIm age doesn't
like Indexed pixel format

//Create a graphics object attached to the new bitmap
Graphics newBmpGraphics = Graphics.FromIm age(newBmp);
newBmpGraphics. InterpolationMo de = InterpolationMo de.HighQualityB icubic;

newBmpGraphics. ScaleTransform( (float)xScaleFa ctor, (float)yScaleFa ctor);
Rectangle drawRect = new Rectangle(0, 0, inputBmp.Size.W idth,
inputBmp.Size.H eight);

newBmpGraphics. DrawImage(input Bmp, drawRect, drawRect,
GraphicsUnit.Pi xel);
newBmpGraphics. Dispose();
return ConvertBitmap(n ewBmp, inputBmp.RawFor mat);
}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
1 2427
Hi James,

From my point-of-view, you've got to choose:

A) QUALITY (InterpolationM ode.HighQuality Bicubic)
B) SPEED (InterpolationM ode.NearestNeig hbor)

....and from my practise i can say that speed difference
can be greater than 8x (depends on image size)

Regards

Marcin
I have tried a few different methods for scaling an image down but all
seem a bit on the slow side. Is there any way i can make this scaling
faster.......
Here is how i do it now.
To display my image at 1:2 zoom i have the following
xScaleFactor = 0.5
yScaleFactor = 0.5
public static Bitmap ScaleBitmap(Bit map inputBmp, double xScaleFactor,
double yScaleFactor) {
//Create a new bitmap object based on the input
Bitmap newBmp = new Bitmap((int)(in putBmp.Size.Wid th*xScaleFactor ),
(int)(inputBmp. Size.Height*ySc aleFactor),
PixelFormat.For mat32bppArgb);//Graphics.FromIm age doesn't
like Indexed pixel format

//Create a graphics object attached to the new bitmap
Graphics newBmpGraphics = Graphics.FromIm age(newBmp);
newBmpGraphics. InterpolationMo de = InterpolationMo de.HighQualityB icubic;

newBmpGraphics. ScaleTransform( (float)xScaleFa ctor, (float)yScaleFa ctor);
Rectangle drawRect = new Rectangle(0, 0, inputBmp.Size.W idth,
inputBmp.Size.H eight);

newBmpGraphics. DrawImage(input Bmp, drawRect, drawRect,
GraphicsUnit.Pi xel);
newBmpGraphics. Dispose();
return ConvertBitmap(n ewBmp, inputBmp.RawFor mat);
}

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #2

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

Similar topics

1
4289
by: Ron Crump | last post by:
Hi, I have a small javascript (scalegr.js) that re-scales a sequence of images on a page to be less than the frame width, thus: function scalegr(a) { var imgs = document.images; var fw = window.innerWidth; for (var i=0; i<imgs.length; i++) { var w=imgs.width;
11
16475
by: Stephane D'Alu | last post by:
Do you know if it is possible to have an image to be scalled to a maximum width/height, but with keeping its aspect ratio. The two ideas I had were: - <img src="toto.jpg" style="max-width: 200px; max-height: 200px;"/> but it doesn't keep the ratio - <div style="width: 200px; height: 200px;"><img src="toto.jpg/></div> but the image flow outside the div
1
1807
by: susie_richie_30 | last post by:
Hi, I am trying to apply gray scaling to color as well as black/white images. I have tried using the pixel by pixel approach to achieve the scaling. But the particular approach has a issue with high mega pixel images. Is there any other approach that can be applied to achieve the gray scaling and also have a reasonable performance?
0
1270
by: Steven | last post by:
Hello, I have a problem in scaling printing. I use standard print dialog. When I click the button of "Property" in this dialog, it shows the printer's property dialog. As usual, there is a function of "scaling" in the printer's property dialog. But how can I get the value of this "scaling" in C#.net? Could you tell me the method? Thanks.
0
1205
by: Steven | last post by:
Hello, I have a problem in scaling printing. I use standard print dialog. When I click the button of "Property" in this dialog, it shows the printer's property dialog. As usual, there is a function of "scaling" in the printer's property dialog. But how can I get the value of this "scaling" in C#.net? Could you tell me the method? Thanks.
0
946
by: Larry | last post by:
1.Any best practices to scaling managed components? 2. Any best practices to get high performance from managed components? *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
3
2549
by: Larry Serflaten | last post by:
I am taking a 256 color bitmap from a file and scaling it up X 16 to a 32bppPARGB bitmap in memory. I copy that image to the screen. After scaling, the edges of all the lines and colors are blurred. I want the edges all crisp, including inherent pixelation (jaggies). Setting smoothing to none, or adjusting the composting mode on the Graphics object still
17
2631
by: IanIpp | last post by:
We have a 3 month old quad processor/dual core server running SQL Server 2005 and already it is getting close to hitting the CPU wall. An 8 way CPU box is prohibitively expensive and out of the question. I am looking desperately for a way to TRULY scale out SQL server...in the same way that IIS can be scaled out via App Center. The "in the box" solution for SQL Server 2005 scaling out is the DMV. Unfortunately this solution makes...
19
1545
by: Ant | last post by:
Hi all, I have a question on PyParsing. I am trying to create a parser for a hierarchical todo list format, but have hit a stumbling block. I have parsers for the header of the list (title and description), and the body (recursive descent on todo items). Individually they are working fine, combined they throw an exception. The code follows:
0
7928
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8405
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
6735
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5441
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3951
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2430
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 we have to send another system
1
1514
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1259
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.