Windows Store App TileMode in ImageBrush is missing - c#

I read this link How to TILE a background image in WinRT?
I need to have a background image for example 300*1000 pixel i have base image in 300*10 pixel and i want to repeat this base image for the background
i use this line and really TileMode is not in this version of Metro/XAML.
<ImageBrush ImageSource="ms-appx:///Assets/Note.png" Stretch="None" AlignmentY="Top" x:Name="my_image" >
i want to have to repeat "my_image" for 100times!
have can i do that? is there any idea?
thnak for your attention

Related

how can I give an image an octagonal shape?

I'm creating a mobile App. In this app there is the user's profile and i would like give an an octagonal shape to the user's profile. For the moment I have just an image:
<Image x:Name="ProfilePicture" HeightRequest="100" HorizontalOptions="Center" Source="Profile.png" TranslationY="50" VerticalOptions="End"/>
how can I shape this image?
The result I would like to achieve is this:
a yellow outline and instead of the gift the user image
Xaml doesn't support drawing shapes directly. You have several options:
Simple. Use shape image as resource. Put it all together with with grid or absolute layout.
Smart. Use Font Awesome icons in your XF. You can reuse other icons to reduce bitmaps in your app. Unfortunately octagonal shape is available only in PRO edition.
Heavy artillery. You can use Skiasharp or similar library to draw octagonal image with user image inside.
Hope it helps.

Wpf shared image memory

I want to optimize the memory usage in my WPF app.
I want to load from the disk an jpg image and show it with its real size.
And then I want to show 5 cropped square section of the original image loaded from the disk.
(No resize is applied on any image).
I want to do all this by loading the original image once and sharing that data among the image controls, in such a way that no memory is wasted and all controls fetch data from the same memory location.
I tried by using a memory stream object but in the end due to some convertions between bitmap and bitmapimage I ended up copying the data.
I found an interesting way to crop an image from a BitmapImage here that I think will solve your problem. Doing it this way, you can display all of your images just using a single BitmapImage
In your xaml your full resolution image would just be a regular image element, but your cropped images would be a rectangle element using an image brush with a specific viewbox. Just define the rectangle with the height and width of the cropped image that you want, and then the viewbox is defined as "x y width height" (in my example it is "10 20 100 200") and remember that x starts at 0 for left and is positive moving right, and y starts at 0 for the top and is positive moving down.
<Image Source="{Binding Image}"></Image>
<Rectangle Height="200" Width="100">
<Rectangle.Fill>
<ImageBrush ViewboxUnits="Absolute" Viewbox="10,20,100,200" ImageSource="{Binding Image}"></ImageBrush>
</Rectangle.Fill>
</Rectangle>
Note that the binding for the Image and the ImageBrush are the same, so you only need to define Image once, and it is used across both elements.

Circular CaptureElement camera stream in Windows 10

Wherever you look in Windows 10, there are circles. It's fairly easy to make images circular, but camera is a bit different. Is there a simple XAML way to clip the camera stream in a CaptureElement to make it a circle?
I tried putting it in a border, but CaptureElement doesn't care about its borders. I also tried using the Clip property, but it can only clip to RectangleGeometry.
One way would certainly be to grab CaptureElement frames, transforming them to images (frame by frame) and applying to Image element, and then clipping the image, but it seems like that would have awful performance.
Is there something in the framework to make this really simple, but I'm not seeing it?
Well after seeing that might be the background is always black of the Canvas DirectX the only way I see is:
1.- Clip a rectangle with an ellipse in Inkscape for instance.
2.- Copy to Expression Design and Ctrl-Shift-C (to copy XAML)
3.- Place inside a ViewBox only the path generated
<Grid Width="300" Height="300">
<CaptureElement Name="PreviewControl" Stretch="Uniform" Width="280" Height="280" />
<Viewbox Width="280" Height="280">
<Path Width="813.701" Height="813.701" Canvas.Left="-33.3503" Canvas.Top="-45.3503" Stretch="Fill" Fill="#FF800080" Data="F1 M -33.3503,-45.3503L -33.3503,768.35L 780.35,768.35L 780.35,-45.3503L -33.3503,-45.3503 Z M 373.54,158.095C 485.863,158.095 576.985,249.137 576.985,361.54C 576.985,473.863 485.863,564.985 373.54,564.985C 261.137,564.985 170.095,473.863 170.095,361.54C 170.095,249.137 261.137,158.095 373.54,158.095 Z "/>
</Viewbox>
</Grid>
With that you can place an image in the path or a solid color, that's the only way I see to do it. Hope it helps

Tint a partially transparent image in WPF

How can I tint/colorize an image in WPF (using MVVM) without sacrificing performance? A purely XAML solution would be ideal, as modifying bitmaps in the code will cause performance loss with lots of changing images. The image is made up of more than simple shapes, so it is not possible using a path.
Unlike WinForms/GDI+, WPF does not seem to contain any easy ways to colorize/tint an image as it is being rendered. Two ideas for accomplishing this are, using a shader, or overlaying a colored rectangle over the image.
I decided to try the rectangle route and found that it works. Basically, all you need to do is overlay a colored rectangle over your image, and use an OpacityMask to restrict the color fill to a certain area. OpacityMask is primarily used with paths, but it can take any kind of brush, including an ImageBrush. This means you can use your image as a "stencil" for the colored fill.
Example: (Taken from my application where a user can "highlight" a section of a map, the actual image looks like this)
Before Overlay & Mask
After Overlay & Mask
Here is all of the required XAML for this:
<Image
Source="{Binding MyImage}"
Width="150"
Height="150" />
<Rectangle Width="150" Height="150">
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color}"/>
</Rectangle.Fill>
<Rectangle.OpacityMask>
<ImageBrush ImageSource="{Binding MyImage}"/>
</Rectangle.OpacityMask>
</Rectangle>
To bind the color to a brush as I did, use a ColorToBrushConverter.

How to blur image's edges after clip on winPhone?

I have clipped Image:
<Image Name="Img" Source="/UntitledImage.jpg">
<Image.Clip>
<EllipseGeometry Center="115,115" RadiusX="50" RadiusY="50"></EllipseGeometry>
</Image.Clip>
</Image>
or:
<Image Name="oldImg" Source="/UntitledImage.jpg">
<Image.Clip>
<RectangleGeometry Rect="115,115,50,50"></RectangleGeometry>
</Image.Clip>
</Image>
I want added blur for each edge for Image after clip.
I want manage thick blur area for Image.
Is it possible?
Rather than creating a blurred version of each image, why not put a semi-transparent image over the top of the image to give the appearance of a blurred edge instead?
This would, I expect, be much quicker and simpler.
This solution might be a little heavier for your purpose, but I suppose it will serve any need you could have.
You can try to use Nokia Imaging SDK to process your images. The SDK usage is very simple and well documented In the developer library.
Also, before you decide, the link above contains sample apps to explore the effects.

Categories