c# - Image added to WPF canvas changes size -
c# - Image added to WPF canvas changes size -
as part of application, have canvas object <canvas name="canvas"/>
trying insert components of clock follows
// add together background image bg = new image(); bg.setvalue(canvas.zindexproperty, 0); bg.source = new bitmapimage(new uri("images/background.png", urikind.relative)); canvas.width = bg.source.width; canvas.height = bg.source.height; canvas.children.add(bg); // add together sec hand image hand = new image(); hand.setvalue(canvas.zindexproperty, 10); hand.source = new bitmapimage(new uri("images/hand.png", urikind.relative)); canvas.children.add(hand);
the first image (bg) appears correctly sec 1 (hand) appears scaled (original size 5 x 61 pixels, interrogating image size after creation shows has become 6.66 x 84.02 display units) (bg original 130 x 130 pixels , shows 130.4 in display units)
all answers query can find (stackoverflow , google) suggest dpi setting of image both images 96 dpi (according paint) have tried moving image declarations xaml (not long term solution) makes no difference. have tried changing order in insert images no effect. have set canvas width/height explicitly in xaml - no effect. have set size of image explicitly - 1 time again no effect.
can tell me going on?
added: compiled using .net 4 on windows7 64bit
resolved: paint reporting wrong dpi setting image. paint.net gave me right value , changing 96 dpi problem resolved
issue resolved: paint reporting wrong dpi. using alternate paint bundle (paint.net) showed dpi different. correcting setting fixed issue.
c# wpf image wpf-controls
Comments
Post a Comment