Setting ImageSource in Coding4Fun RoundButton Not Scaling - c#

I am trying to create a button that is the exact same look and feel as a regular Windows Phone 8 application bar button. I am using the Coding4Fun RoundButton for this. My issue is that when setting the ImageSource I cannot get the image to scale to fit inside of the button properly, it is far too big. I am using a standard application bar icon image from the Windows Phone 8 SDK, whch is 76x76. I've also resized to mimic the Windows Phone 7 icon size of 48x48 but the same result occurs. How can I adjust the image so it fits in the RoundButton properly?
XAML
<c4f:RoundButton x:Name="browseRoundButton" Click="Browse_Click"/>
XAML.CS
if (Settings.LightTheme.Value)
browseRoundButton.ImageSource = new BitmapImage(new Uri("/Assets/Icons/feature.search.light.png", UriKind.Relative));
else
browseRoundButton.ImageSource = new BitmapImage(new Uri("/Assets/Icons/feature.search.dark.png", UriKind.Relative));
EDIT* In referencing sources like http://www.geekchamp.com/articles/wp7-roundtogglebutton-and-roundbutton-in-depth and http://coding4fun.codeplex.com/discussions?searchText=roundbutton I cannot seem to find any solutions.

My solution to this was to set the ImageSource in the XAML (using only the dark style icon) and ensure the size is 48x48. Works Great!

Related

Is there a way to prevent from Windows AutoScale my forms?

One of my forms takes screenshot of desktop and uses it as form background for drawing on it. But when the Windows setting "Desktop/Screen resolution/Make text and other items larger or smaller" is greater than 100% the Screen.Bounds is smaller then Image.Size. So the background image is bigger than form. Streching the screenshot image couses blurring.
So what is the solution for proper size screenshot?
Preventing Windows from AutoScaling my form or another way of screenshot?
SendKeys.SendWait("{PRTSC}");
Image img= Clipboard.GetImage();
this.BackgroundImage = img;
Debug.Print("Img.Size=" + img.Size.ToString());
Debug.Print("Screen.Size=" + Screen.PrimaryScreen.Bounds);

How to display scaled image without anti-aliasing?

Question
How can I scale an image in XAML quickly without anti-aliasing applied?
Background
I am trying to make a pixel editor as a Windows 8 XAML/C# app. I'm using c#/XAML because most of my experience is with c#/WPF.
Method 1: WriteableBitmap + Image control. Originally, I used a WriteableBitmap to store and edit an image. That image is displayed in a resized XAML Image control. The problem is that the image does not get scaled properly because of anti-aliasing. (XAML does not seem to provide the BitmapScalingOptions that are available in WPF)
Method 2: Redrawn WriteableBitmap + Image control. Next I tried writing my own scaling, where I take my original image and write to a larger WriteableBitmap so that the scaled image is pixelated. The scaled image is then presented inside a XAML Image control. This process is slow and inefficient.
Method 3: SharpDX + Direct2d ?? I am pretty sure a solution exists somewhere between SharpDx, SurfaceImageSource, and Direct2d. Event still, I can't quite figure out how to display a SharpDx.WIC.Bitmap inside a Windows.UI.Xaml Image control, and am generally getting lost in the documentation.
What exactly is a recommended setup for achieving my desired end? Are there c# samples available which might point me in the right direction?
I don't know if you mean by scaling it by resizing it with the mouse or just with a button click to auto scale to a predetermined size.
But the thing you can do is to use an Image panel and then, just set it to image.Stretch = Stretch.Fill; so if you override and create a method for the Resize event of the Image Panel, your image will take the size to fill the Image panel.

How can i save UI Element as a image in Windows Phone 8?

Currently i'am developing app that will be possible to share image, with information take it of longlistselector as is showed in app, i'am trying save an ui element as a image, i don't know how can i achieve this task.
In android i realized that is possible to do this with getDrawingCache , but in windows phone 8 if is it possible?. I won´t to create new image with each element of LLS,
How can i save UI longlistselector as a image in windows phone?
I tried to do screen shoot of the current view, but not of all elements of LLS are visible.
Thanks in advance!.
Put this code to the Image where you want to render and apply as source
var writeableBitmap = new WriteableBitmap((int)YourLongListSelector.RenderSize.Width, (int)LongListSelector.RenderSize.Height);
writeableBitmap.Render(YourLongListSelector, new ScaleTransform() { ScaleX = 1, ScaleY = 1 });
writeableBitmap.Invalidate();
image.Source = writeableBitmap;

windows phone image overlay

I want to know how to overlay one image over the over in Windows Phone. I did some search online, a lot of people suggest put two images into one grid and adjust the margin. However, my case is a little different. I'm making the background image of the secondary tile, I want to integrate the two images, store it locally and make the tile. So I can't put them into a grid. So what should I do in this case? Thanks!
You can create UserControl with any layout you wish (173x173px). Then, when you need to generate a tile, put this control to a page (probably out of the screen) and make and image from it with new WriteableBitmap(YourTile, null);. Than save these image to the /Shared/ShellContent/ and you are done
Probably there are better solutions for this task but this works fine too
I made this work using Ku6opr method using the following
WriteableBitmap bmp = new WriteableBitmap(173, 173);
bmp.Render(renderRoot, new TranslateTransform());
bmp.Invalidate();
where renderRoot is the usercontrol containing the Grid and the Image. I then save the bmp to the /Shared/ShellContent folder in Isolated storage.

How do I set the transparency key for a button in windows forms?

I'm using standard BMP images for buttons that come with visual studio. When using these images within a resource (resx) file, how do I set the transparency key?
This has always worked fine for me using an ImageList, but I want to reuse the images among many dialogs within the same assembly which I would also like the ability to control the images through resource bundles allowing for image localization.
Some of the images I'm talking about can be found in:
%VS_PATH%\Common7\VS2008ImageLibrary\1033\VS2008ImageLibrary\VS2008ImageLibrary\Annotations&Buttons\bmp_format
You can do it through the designer. Add an ImageList to your form and set its TransparentColor property. Add the image. Set the button's ImageList and ImageIndex properties.
Although I wanted to do it through the designer I think this is the only way I can figure out how to achieve what I'm after.
Bitmap bmp = new Bitmap(MyAppResources.MyImageResource);
bmp.MakeTransparent(Color.Fuchsia);
Button btn = new Button();
btn.Image = bmp;

Categories