xamarin.ios - IOS drawing a simple image turns out blurry using Xamarin C# -
i'm developing in xamarin , draw simple circle text "circle" inside , display image in uiimageview. problem circle , text appear blurry. i've read bit subpixels don't think that's problem.
here's blurry image , code, hoping has ideas :)
uigraphics.beginimagecontext (new sizef(150,150)); var context = uigraphics.getcurrentcontext (); var content = "circle"; var font = uifont.systemfontofsize (16); const float width = 150; const float height = 150; context.setfillcolorwithcolor (uicolor.red.cgcolor); context.fillellipseinrect (new rectanglef (0, 0, width, height)); var contentstring = new nsstring (content); var contentsize = contentstring.stringsize (font); var rect = new rectanglef (0, ((height - contentsize.height) / 2) + 0, width, contentsize.height); context.setfillcolorwithcolor (uicolor.white.cgcolor); new nsstring (content).drawstring (rect, font, uilinebreakmode.wordwrap, uitextalignment.center); var image = uigraphics.getimagefromcurrentimagecontext (); imageview.image = image;
the reason why it's blurry because resized. bitmap not 150x150 (like context created), it's 333x317 pixels.
it because imageview
scaling it's image (there's no source code) or because of pixel doubling (for retina displays). in later case want use is:
uigraphics.beginimagecontextwithoptions (size, false, 0);
which (using 0
) automagically use right scaling factor retina (or not) display - , crisp (and not oversized) on types of devices.
Comments
Post a Comment