Hi
Via an adapted Paint-method I try to zoom in on a part of a bitmap (8 x 8
pixels). So I defined the source rectangle of the image and the destination
rectangle on my application form (see code). That works well, but the pixels
of the first row and the first column are only rendered for half the size.
Can anyone explain that ...?
Thx
Frans
protected override void OnPaint(PaintEv entArgs e)
{
// destination rectangle
Rectangle rectDst = new Rectangle();
rectDst.X = 0;
rectDst.Y = 0;
rectDst.Width = 320;
rectDst.Height = 320;
// source rectangle
Rectangle rectSrc = new Rectangle();
rectSrc.X = 0;
rectSrc.Y = 0;
rectSrc.Width = 8;
rectSrc.Height = 8;
// draw (part of the image)
Graphics g = e.Graphics;
g.Interpolation Mode = InterpolationMo de.NearestNeigh bor ;
g.DrawImage( Bm, rectDst, rectSrc, GraphicsUnit.Pi xel );
} 2 3462
This is a common problem. Set the PixelOffsetMode to half.
--
Bob Powell [MVP]
Visual C#, System.Drawing
Ramuseco Limited .NET consulting http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
"Frans Vander Meiren" <Fr************ ***@discussions .microsoft.com> wrote in
message news:3E******** *************** ***********@mic rosoft.com... Hi
Via an adapted Paint-method I try to zoom in on a part of a bitmap (8 x 8 pixels). So I defined the source rectangle of the image and the destination rectangle on my application form (see code). That works well, but the pixels of the first row and the first column are only rendered for half the size. Can anyone explain that ...?
Thx Frans
protected override void OnPaint(PaintEv entArgs e) { // destination rectangle Rectangle rectDst = new Rectangle();
rectDst.X = 0; rectDst.Y = 0; rectDst.Width = 320; rectDst.Height = 320;
// source rectangle Rectangle rectSrc = new Rectangle();
rectSrc.X = 0; rectSrc.Y = 0; rectSrc.Width = 8; rectSrc.Height = 8;
// draw (part of the image) Graphics g = e.Graphics; g.Interpolation Mode = InterpolationMo de.NearestNeigh bor ; g.DrawImage( Bm, rectDst, rectSrc, GraphicsUnit.Pi xel ); }
Thanks Bob. It works ...
"Bob Powell [MVP]" wrote: This is a common problem. Set the PixelOffsetMode to half.
-- Bob Powell [MVP] Visual C#, System.Drawing
Ramuseco Limited .NET consulting http://www.ramuseco.com
Find great Windows Forms articles in Windows Forms Tips and Tricks http://www.bobpowell.net/tipstricks.htm
Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/faqmain.htm
All new articles provide code in C# and VB.NET. Subscribe to the RSS feeds provided and never miss a new article.
"Frans Vander Meiren" <Fr************ ***@discussions .microsoft.com> wrote in message news:3E******** *************** ***********@mic rosoft.com... Hi
Via an adapted Paint-method I try to zoom in on a part of a bitmap (8 x 8 pixels). So I defined the source rectangle of the image and the destination rectangle on my application form (see code). That works well, but the pixels of the first row and the first column are only rendered for half the size. Can anyone explain that ...?
Thx Frans
protected override void OnPaint(PaintEv entArgs e) { // destination rectangle Rectangle rectDst = new Rectangle();
rectDst.X = 0; rectDst.Y = 0; rectDst.Width = 320; rectDst.Height = 320;
// source rectangle Rectangle rectSrc = new Rectangle();
rectSrc.X = 0; rectSrc.Y = 0; rectSrc.Width = 8; rectSrc.Height = 8;
// draw (part of the image) Graphics g = e.Graphics; g.Interpolation Mode = InterpolationMo de.NearestNeigh bor ; g.DrawImage( Bm, rectDst, rectSrc, GraphicsUnit.Pi xel ); } This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Harry_Crow |
last post by:
I'm painting in the Non Client area of the control. I'm facing some flicker
problem. Is it possible to achive Double buffer painting in Non Client area.
The SetStyle with ControlStyles.DoubleBuffer and
ControlStyles.AllPaintinginWmPaint set to true only works for Client area
painting,
Please Help me if any one has some Idea.
Thank you,
|
by: Deano |
last post by:
I think that just about sums it up. Is there a fix/workaround for this?It's
quite annoying behaviour and not user-friendly.thanksMartin
|
by: Gopi |
last post by:
Hi All
I have set a BackgroundImage for windows forms and i need
to implement the image zooming feature for the form ie
when ever i m zooming in or zooming out the form the
corrosponding background image also needs to be zoomed in
and zoomed out. the zoom factors ( zooming values are)
50%,100% and 150% how do i implement this?
thanks in advance
Gopi
|
by: Bernie Yaeger |
last post by:
I'd like to allow the user to zoom a window using a trackbar, say from 80%
to 120% the size of the original window. I'm trying to do this with the
following code, but it fails pretty miserably:
(from the form)
Dim per As Decimal
per = CDec(zoomit.Value)
setzoom(Me, Me.Font, per) ' per is the current value of the trackbar as a
|
by: gerstla |
last post by:
hi
I am building a simple control to view images with zooming capabilities. i want the image to zoom when it is clicked on. after zooming i want the control to try and move the point clicked to the center or at least be in view.
The code I am using know for centering isnt working correctly.
AutoScrollPosition = new Point((int)(currentPoint.X * _zoom), (int)(currentPoint.Y * _zoom));
currentPoint is the last place I clicked.
thanks
| |
by: pavanjosh |
last post by:
Hello Frineds,
Can anyone please help me in getting the code or library for written in C# for zooming in and zooming out the images in the picture box? Or is there any other way from which i can achieve the same task?
Your help will be gretely appreciated.
Thanks and Reagrds
Pavan Joshi
|
by: =?Utf-8?B?U3BlZWR5?= |
last post by:
Hi there,
I am currently writing an application where one inspects images and
annotates certain features. Thus, one has to zoom in (4x) and pan around. The
features are marked with little red rectangles.The images are 2048x2048
pixels.
It seems that I can find no efficient way to implement both zooming and
panning.
At present I have a panel with autoscroll set to true inside which there is
|
by: johot |
last post by:
I am currently creating a little photo application. In this application the user is able to zoom in the image and after zooming panning around inside the zoomed image with the mouse. The strange thing is that the first zoom is really slow, and so is the first panning. So if you zoom into an image it will first take some time, and when trying to pan the image around things will be really choppy.
However if i zoom into the image even more, and...
|
by: Marina Levit |
last post by:
I am trying to do some processing on a background thread while keeping the
UI painting. However, this is a generic server side call routine - and it
needs to block until the server side call completes. So the idea is, a
server side call begins, it gets spun off on another thread to keep the UI
painting - but, the code flow cannot return to the caller until the server
side call completes, because the caller expects the data.
The only way...
|
by: alarock |
last post by:
how can i do Zooming of a particular area using OnMouseWheel (that is zooming a mouse wheel point that should come into view with zoom ) using C#
Regards,
ALGATES
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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,...
|
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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...
| |
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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
| |