saving aspx page into an image - c#

need to convert, an aspx page with a panel having image and some labels into it, as an image
in details i would say i need to save the image some text content on it as a new image...
please help soon running out of target...

Write a winforms app with a WebBrowser control in it. Tell the WebBrowser to load the url, wait for it to finish and then use this to paint your form into a bitmap. Use BitMap.Save to save the final image.

Just make a screenshot. Either by printscrn or by code.

Related

Get all points of Image to redraw c#

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

Save Image in PictureBox with overlapping Controls

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.

Cast IFRAME into Bitmap

is it possible if I get an IFRAME elemenet from my webBrowser and cast it into a bitmap? The IFRAME uses src attribute that points to a dynamic image.
Usually what I do when I want to do this with an IMG element, is I copy it to clipboard IHTMLControlRange and then cast it to bitmap from there.
This doesn't seem to work for IFRAME, anyone have a solution?
You should be able to use print screen functionality, mimicking an ALT-Print Screen action. That will give you the window as a bitmap, which includes the iFrame, and then you'd need to zero in on the exact coordinates and crop the bitmap.
Here is another SO question that addresses the print screen functionality for C#:
.NET 2.0 WinForm print screen
Here is an article on cropping an image in C#:
http://msdn.microsoft.com/en-us/library/7wt4bf7h.aspx
EDIT: Changed the URL I originally posted for image cropping...that was more specific to WPF, sorry.

Remove jquery script from a control

I am coding a galery in jquery.
I have an image zoom tool that is put on a main image on an image_preload event.
I have smaller images that when clicked swaps the main image out with the one that is clicked. The new image is now the main image.
The problem is that the zoom tool is still picking up the old image even though in firebug it says that the new image was loaded into the zoomer.
I want to remove the code that i have on the main image when the switch is made and then put it back on. I'm thinking this will update the zoomer.
i have
$('.MYCLASS').jqzoom();
so can i do something like
$('.MYCLASS').jqzoom().Remove();
Thanks any help is appreciated
You would have to know what the function does in order to reverse its effects. It might be that the plugin provides a remove function, but I doubt that it would work in your instance.
One suggestion might be to simply clone the $('.MYCLASS') element and delete the original which has been bound with the jqzoom() plugin.

Screen Capture Feature Overrides

what i want to do is write an application in C# like "fraps" and other scren capture apps that when you press the "Print Screen" it saves the current screen as an image.
What i thought of is that
"i could create a background worker thread that checks the clipboard after x seconds and if there is an image, that is now in clipboard because of print screen click, it writes the clipboard contents to a jpeg or bitmap file" bu i lack the following knowledge
How will i know that there is an image in clipboard or some text or file
how to write that clipboard to an image file like how to convert that data into a JPEG (LZ-W format) or bitmap format etc.
Can anybody endow me with some knowledge or guide or help from C# coding prespective
The saving to a particular format is incredibly easy thanks to the Image class:
myImage.Save("someimage.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
As far as checking the clipboard, well you can do this, but i think you might run into issues that you won't know whether the image came from a Print-Screen, or from a Ctrl-c that the user did. However you can easily check the clipboard:
if (Clipboard.ContainsImage())
myImage = Clipboard.GetImage();

Categories