So, I'm trying to save an canvas content as an image. I'm using this for it:
var img = new WriteableBitmap(myCanvas, null);
Problem is that the image is not showing all the content inside of the canvas. If there's a button, an image or other similar objects, they do not show.
I can see an ellipse, but if I set an image as background, the background stays empty.
Is there anyway to solve this?
Try to use Image Tools from codeplex and read this and this
Related
i create a panel and inside this panel i create a picture box. this have no default image. after a function i load a image und put it into this picturebox. the image was bigger as the panel and i want to scroll the image but the image draw only in the first area to see and if i scroll the image dont draw complete. how i can fix this ?
Image TreeImg = new Bitmap(imgPath);
maletreePictureBox.Width = TreeImg.Width;
maletreePictureBox.Height = TreeImg.Height;
maletreePictureBox.Image = TreeImg;
actionPanel.AutoScrollMinSize = new Size(TreeImg.Width, driverTreeImg.Height);
this is the result
Set the .Dock property of the maletreePictureBox to Fill.
Also it looks like your AutoScrollMinSize Height property is incorrect (driverTreeImg.Height instead of TreeImg.Height)
Hi so I'm making an app for Windows 10 that requires a user to choose an image and it's going to crop the image to 310*128. I got the file picker code already. But I want to know how to actually crop and save the image and display in image box. I already have the xaml page done
With Lumia Imaging SDK you can both crop the selected image and resize the image. In this answer I assume you actually want to crop, but from the text I could just as well guess you really just want to resize.
For crop, use the CropEffect from Lumia.Imaging.Transforms. Set the CropArea property on it to the object, and then render it. If you are rendering straight to the XAML page I recommend using a SwapChainPanel object in XAML and a SwapChainPanelRenderer to render on it.
Given that you are loading a StorageFile and rendering to a SwapChainPanel your code might look like something like this:
StorageFile file = ...
using (var source = new StorageFileImageSource(file))
using (var crop = new CropEffect(source, new Rect(0, 0, 310, 128))
using (var renderer = new SwapChainPanelRenderer(crop, YourSwapChainPanel))
{
await renderer.RenderAsync();
}
I am developing an application in which user can select an image in a picture box.
After that he can right click on the image and add a user control which will again display an Image along with some text. This user control can be added any number of times.
User can also re-position the user controls as per need.
All this functionality has been implemented and is working fine.
Now, the requirement is to save the Image along with the user control.
Above you can see the complete image which needs to be saved. Back image is the picture box image and the user control (small images with text).
When user will click on save button the image should get saved on his disk as a single image.
This is a windows application developed in C#.
I want to know that whether this functionality can be achieved or not. If yes, then please guide me in the right direction.
If you create a copy of the bitmap then with the Graphics.DrawImage() you can draw those images onto it. You need to calculate the position of those controls.
Look here for DrawImage: http://msdn.microsoft.com/en-us/library/42807xh1.aspx
example:
Bitmap copy = new Bitmap(OriginalBitmap);
Graphics g = Graphics.FromImage(copy);
g.DrawImage(arrowBitmap, new Point(..));
copy.Save(...);
A very simple and straight forward solution exists, has been thought of by Microsoft and includes these steps:
Instead of PictureBox use a Panel and instead of using the Image property of the PictureBox use the BackgroundImage property of the Panel
note: By using also the BackgroundImageLayout property you can quite easily instruct the Panel to stretch, center or zoom the image (I'm presuming the default value which is tile is not a good option in your case)
Instead of placing the other user controls at higher Z order but alongside the previous PictureBox place them inside the Panel
Use the Control.DrawToBitmap method like so:
private void button1_Click(object sender, EventArgs e) {
var bmp = new Bitmap(this.panel1.Width, this.panel1.Height);
this.panel1.DrawToBitmap(bmp, new Rectangle(Point.Empty, bmp.Size));
bmp.Save(#"D:\test.png", ImageFormat.Png);
}
That will result in your controls begin rendered along with the picture:
Furthermore, and if your scenario allows it, you could simply use the DrawToBitmap method with any control which contains all of the actors you wish to render, for instance the actual Form.
I want to show a background image on my app's navigation bar.
Showing the image works:
UIImage image = new UIImage( #"Images/navbarlogo2.png");
UIImageView imageview = new UIImageView(image);
NavigationItem.TitleView = imageview;
But the image is centered, while I need it to be right-aligned.
I have not been able to find a property to do this, and searching yielded no answers.
You could use the following method to set your navbar's background image. Note that this will set it as the default for all the nav bars and is available since iOS5.
UINavigationBar.Appearance.SetBackgroundImage(image, UIBarMetrics.Default);
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.