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
yields blurred edges. What do I need to do
to the scale up the image, pixel for pixel?
The bitmaps are created like:
Maps = DirectCast(Bitmap.FromFile("..\images\maps.bmp"), Bitmap)
LargeMap = New Bitmap(MapSize.Width * 16 + 4, MapSize.Height * 16 + 4, Imaging.PixelFormat.Format32bppPArgb)
Then later;
Dim grx As Graphics = Graphics.FromImage(LargeMap)
grx.Clear(Color.DarkGreen)
grx.SmoothingMode = Drawing2D.SmoothingMode.None
grx.CompositingMode = Drawing2D.CompositingMode.SourceCopy
grx.DrawImage(Maps, New Rectangle(0, 0, MapSize.Width * 16, MapSize.Height * 16), _
New Rectangle(0, Index * MapSize.Height, MapSize.Width, MapSize.Height), _
GraphicsUnit.Pixel)
The image should be scaled there, and is later copied to the screen:
Dim grx As Graphics = Me.CreateGraphics
grx.SmoothingMode = Drawing2D.SmoothingMode.None
grx.DrawImage(LargeMap, New Rectangle(10, 40, 400, 400), New Rectangle(80, 80, 400, 400), GraphicsUnit.Pixel)
What I see on the screen is blurred, but I suspect I need to address the
problem during the scaling process.
Any/all help will be appreciated....
LFS 3 2543
"Larry Serflaten" <se*******@usinternet.com> wrote
I found it! It was the Nearest-Neighbor interpolation mode I needed.... Setting smoothing to none, or adjusting the composting mode on the Graphics object still yields blurred edges. What do I need to do to the scale up the image, pixel for pixel?
grx.Clear(Color.DarkGreen) grx.SmoothingMode = Drawing2D.SmoothingMode.None
grx.InterpolationMode = Drawing2D.InterpolationMode.NearestNeighbor grx.DrawImage(Maps, New Rectangle(0, 0, MapSize.Width * 16, MapSize.Height * 16), _ New Rectangle(0, Index * MapSize.Height, MapSize.Width, MapSize.Height), _ GraphicsUnit.Pixel)
Larry,
"Larry Serflaten" <se*******@usinternet.com> schrieb: Dim grx As Graphics = Me.CreateGraphics
grx.SmoothingMode = Drawing2D.SmoothingMode.None grx.DrawImage(LargeMap, New Rectangle(10, 40, 400, 400), New Rectangle(80, 80, 400, 400), GraphicsUnit.Pixel)
Just to make sure you don't forget to do that: The 'Graphics' objects in
the snippets you provided "should" be disposed...
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote grx.SmoothingMode = Drawing2D.SmoothingMode.None grx.DrawImage(LargeMap, New Rectangle(10, 40, 400, 400), New Rectangle(80, 80, 400, 400), GraphicsUnit.Pixel)
Just to make sure you don't forget to do that: The 'Graphics' objects in the snippets you provided "should" be disposed...
Thanks for the reminder. Those were 'snippets' and not full examples of
working code. I still had other uses for that object that were not pertinant
to the discussion, and that code did not get included...
;-)
LFS This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
$mogResponse = exec("mogrify -size ${width}x$height " .
$this->locationPath . '/' . $this->fileName . '
-resize ' .
$width . "x$height > +profile " .
$this->thumbLocationPath . '/' ....
|
by: D. Alvarado |
last post by:
Hello,
Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the...
|
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:...
|
by: Harry Putnam |
last post by:
I keep stumbling around with varius alignment tags, even using STYLE
tag with absolute positioning but not getting a simple job done.
I have an arrangment like this:
...
|
by: =?Utf-8?B?SlIx?= |
last post by:
I would like to add text to an image. I have tried to use DrawString and it
works on some images but on others it is very very small. I am pretty sure
it has something to do with the size of the...
| |
by: Yofnik |
last post by:
Hello all,
I need your help. Internet Explorer 6+ has a registry setting (UseHR)
that will automatically scale images for displays with high resolution
(DPI).
I am building a web based...
|
by: Stephan Bourdon |
last post by:
Hi,
Your opinion please on the following subject: Is it acceptable to set
the width and height of an image in ems or percents in CSS?
The advantage for me is that images will scale up or down...
|
by: Amir Michail |
last post by:
Hi,
The following gradient method involves scaling a gradient image. How
would one put a logo on top of such a scaled gradient image without
also scaling the logo image?
...
|
by: Peter May |
last post by:
Hi.
I know the dimensions area visible on the screen and I would like to
picture that there put dynamically, match its size to the window, while
retaining the proportions of course.
For...
|
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,...
|
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...
| |
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...
|
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...
|
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: 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,...
|
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...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |