Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
AnswerRe: Scope issue closing a connection after exception Pin
Pete O'Hanlon27-Jun-12 6:13
mvePete O'Hanlon27-Jun-12 6:13 
AnswerRe: Scope issue closing a connection after exception Pin
Luc Pattyn27-Jun-12 6:20
sitebuilderLuc Pattyn27-Jun-12 6:20 
SuggestionRe: Scope issue closing a connection after exception Pin
kisMicrosoftDev27-Jun-12 6:29
kisMicrosoftDev27-Jun-12 6:29 
GeneralRe: Scope issue closing a connection after exception Pin
Harley Burton27-Jun-12 6:57
Harley Burton27-Jun-12 6:57 
GeneralRe: Scope issue closing a connection after exception Pin
mohancbe27-Jun-12 21:11
mohancbe27-Jun-12 21:11 
AnswerRe: Scope issue closing a connection after exception Pin
Harley Burton14-Aug-19 4:37
Harley Burton14-Aug-19 4:37 
GeneralDrawImage with NearestNeighbor-Interpolation Pin
LionAM27-Jun-12 2:03
LionAM27-Jun-12 2:03 
GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
Luc Pattyn27-Jun-12 9:47
sitebuilderLuc Pattyn27-Jun-12 9:47 
(this gibberish sentence has been necessary to get the message accepted by CP as it "appears to have already been posted")

No I've never seen that function being available. However there are two simple solutions for what you seem to want:

1.
the interpolation is quite simple, it basically is a linear re-scaling, something like:
xNew = x * scaleNew / scaleOld


and then the options determine the petty details.
For one you need a floating point operation, and the result needs turned into an int again; that is where NearestNeighbor comes in (it basically means regular rounding: less than 0.5 becomes 0; 0.5 or more becomes 1). And PixelOffsetMode.Half means 0.5 is added anyways, so I would give this a try:
xNew = floor (*(x+0.5) * floatScaleNew / floatScaleOld)+0.5)


Caveat: one has to be careful with negative values, so when you run some tests, include both positive and negative values (unless negatives are irrelevant to your app).

2.
As a big alternative you could simply use the function they use without having direct access to it; this is how it works:
make a synthetic image, width=your original width, height=1; fill it with a wedge, i.e. the values 0, 1, 2, 3... etc. if it is a gray image; or perhalps (0,0,0), (1,1,1), (2,2,2), (3,3,3) if you prefer a regular RGB image (you may need a modulo-256 then).
now let the system apply your scaling to it (in x direction), yielding a larger image with the same width as your actual scaled image. When you click the actual scaled image, use the mouse position and look into the scaled synthetic image; it will return a pixel value which equals the original x coordinate (or at least the lowest 8-bits of it if your synthetic is RGB).
You can use the same trick in the other direction of course (i.e. there is no need to have a 2-D synthetic image).

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum


modified 27-Jun-12 15:58pm.

GeneralRe: DrawImage with NearestNeighbor-Interpolation Pin
LionAM28-Jun-12 5:16
LionAM28-Jun-12 5:16 
Generallocal group to adam group problem Pin
caknoris27-Jun-12 1:38
caknoris27-Jun-12 1:38 
GeneralRe: local group to adam group problem Pin
lukeer27-Jun-12 2:59
lukeer27-Jun-12 2:59 
GeneralHow to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 0:23
rongvangso727-Jun-12 0:23 
AnswerRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 0:42
professionalEddy Vluggen27-Jun-12 0:42 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
rongvangso727-Jun-12 5:07
rongvangso727-Jun-12 5:07 
GeneralRe: How to make a word in a text modifiable(doubleClick, change color,..) in C# Pin
Eddy Vluggen27-Jun-12 5:40
professionalEddy Vluggen27-Jun-12 5:40 
QuestionHow to put field at bottom of detail section in Crystal report Pin
maheshk_blr26-Jun-12 21:26
maheshk_blr26-Jun-12 21:26 
Questionmove App.Config to AppData folder Pin
Jassim Rahma26-Jun-12 21:04
Jassim Rahma26-Jun-12 21:04 
AnswerRe: move App.Config to AppData folder Pin
Eddy Vluggen27-Jun-12 0:46
professionalEddy Vluggen27-Jun-12 0:46 
GeneralRe: move App.Config to AppData folder Pin
PIEBALDconsult27-Jun-12 3:09
mvePIEBALDconsult27-Jun-12 3:09 
GeneralRe: move App.Config to AppData folder Pin
Cracked-Down28-Jun-12 0:59
Cracked-Down28-Jun-12 0:59 
QuestionStackOverflowException when pressing a specific button on certain computers Pin
brendanpi26-Jun-12 18:46
brendanpi26-Jun-12 18:46 
AnswerRe: StackOverflowException when pressing a specific button on certain computers Pin
OriginalGriff26-Jun-12 19:22
mveOriginalGriff26-Jun-12 19:22 
GeneralRe: StackOverflowException when pressing a specific button on certain computers Pin
brendanpi26-Jun-12 19:31
brendanpi26-Jun-12 19:31 
SuggestionRe: StackOverflowException when pressing a specific button on certain computers Pin
Trak4Net26-Jun-12 19:54
Trak4Net26-Jun-12 19:54 
GeneralRe: StackOverflowException when pressing a specific button on certain computers Pin
OriginalGriff26-Jun-12 21:08
mveOriginalGriff26-Jun-12 21:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.