I'm using Blazor-webassembly (PWA).
I have an image where the user needs to fill in form textboxes on specific places in the image.
I've thought about using SVG images to try to insert the textboxes inside of it. But since these are generated from a png, the path's aren't great and I can't put them on the exact locations inside the image.
Does anyone know another method to insert textboxes inside an image?
Related
I have the following problem:
I have a plot in one of my Prism views. My goal is to generate report from my application which includes generated OxyPlot chart. I use the following line to save the plot to the image:
plot.SaveBitmap(fileName, 960, 540, OxyColor.FromRgb(255, 255, 255));
The problem occurs when I try to save bitmap without previously see the plot in user interface. In this case I get only the blank plot, white bitmap with correct size but without content. There is no axis, no title (the bitmap is simply blank). When I use function to generate XAML instead of Bitmap, the result is the same: no content at all.
I had also noticed that the plot have both Width and Height set to 0 when plot is saving. Setting this values before Save function does not change the result file.
I have tried following codes just before saving image:
plot.InvalidatePlot();
Or even:
plot.InvalidatePlot();
Action emptyAction = delegate { };
plot.Dispatcher.Invoke(DispatcherPriority.Render, emptyAction);
plot.InvalidatePlot();
When I navigate the user interface that I can see the plot: the save function come back to correct behaviour. There are no exceptions, the plot has my data to plot just before saving.
Please, help...
I've had the same issue using oxyplot. I was trying to export the image to a file, but it was only working when I showed it at the screen first. To make it work you will have to define all the model programatically, and bind the model to the XAML. This way you will not have to pass through the view to export correctly.
Based on this post - save a graphics object to a varbinary db column c#, I created a control where I allow the user to draw on the control, and I save the drawn image to a database varbinary column. My problem is when I need to reload the signature and allow user to continue editing. I don't have all the points of the original image, so when I redraw, I only retain the user's edits.
Can somebody pls assist?
I figured it out, I was able to set the image loaded as the image of my picture box control, I used a graphics image from that loaded image. problem solved
This is a WPF newbie's request for suggestions ( so there is no code here )
In my application, I present to the user a canvas onto which he can drag drop shapes, textboxes and images. Kind of like Visio. Now the user wants to save what he created to a file. How do I go about doing that, which classes do I use? And what data format choices do I have? What if I want to save it in XML format?
Most grateful for advice and pointers
You can convert it to a bitmap and then save the bitmap to file. To read it again just use bitmap BMP = bitmap.FromFile(file);
Update..
If you want to save all the changes that have been made you then need to create a file format probably something like:
Circle 1, 15 ,25, 100,250,10
Where the format is:
Shape size, positionx, positiony, rgb value
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.
this might be a long shot but here it goes anyway:
Suppose I have a couple of images inside a folder. Is there a way I can create a blank image and place them (with X and Y coordinates) into it?
Just in case I have not been clear enough, what I would like to do is:
1) Generate a blank image
2) Insert into that blank image some other images
In few words, this should create a blank canvas where I want to insert a few images (pictures, for example) later.
(BTW, this is a Windows project in C#)
Check out the System.Drawing.Image and Graphics.DrawImage() classes in the .Net library. Between them, they should allow you to read, draw and save images.