Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can I save multipage WinForm to PDF & how can I print it?
thanks,
Ofir
A good framework is pdfSharp.
You can capture the form (there are few ways of doing it, this is one sample).
Than write the image stream a pdf object (you can find many samples for this in the pdfSharp web site).
You can use paint method to capture the entire client area of your Form and then use the Print method to print them.
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
then use PrintDocument class to print it.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have used html5 camera capture attribute, when user try to capture image from the devices image gets rotated
Do we need to provide any setting on this?
Can we correct the image rotation using C#?
We are successfully using the following code to capture images and it works fine:
var canvas = document.getElementById("canvas")
var video = document.getElementById("video")
// Start video code omitted...
// Capture function
canvas.width = video.videoWidth;
canvas.height = video.videoHeight;
canvas.getContext("2d").drawImage(video, 0, 0);
var imgData = canvas.toDataURL("image/jpeg")
The image should be fine unless there is some specific hardware configuration not allowing this.
And yes, it is possible to rotate the image using C#. Google it.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm currently working on an application, to automate the generation of tilesets.
Actually my question is fairly simple.
I'm having trouble with seperating the file into tiles.
Is it possible to create seperate images out of a PictureBox or is there another, more effective way?
I want to cut the graphic into tiles, to rearrange them.
You can get a sub-image from a PictureBox relatively easily is the image is just a bitmap. You can use the bitmap classes Clone() method, which takes a Rectangle and PixelFormat.
Bitmap image = pictureBox.Image;
Bitmap subImage = image.Clone(new Rect(0,0,64,64), image.PixelFormat);
The subimage in this case would start at position (0,0) in the image and by 64x64 in size
In order to rearrange your tiles you can print them back onto the PictureBox like so:
Graphics g = Graphics.FromImage(image);
g.drawImage(subImage, 64, 64);
pictureBox.Image = image;
This will draw subImage into the image at (64,64) we grabbed from the picturebox, image, earlier and then set the PictureBox image to the edited one.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm developing game in which I choose picture from the gallery and then what I need to do is cut it into 12 custom shape part which will be used then as a puzzle I need those 12 piece to merge together and create the same.
Edit: To those who don't understand the question what i'm trying to accomplish is trying to split an single image into different part and then player will figure out the sequence of part and make the image.
I want the player to add the picture from his/her collection to make it more challenging and challenge others player.
A picture will make it more clear but as I don't have enough credit and i'm getting -ve one in this i don't know how to put it more clearly in the reader mind.
A possiblilty for which you are looking for is masking feature of UI components. You can deal with the flag Show mask graphics to show/hide the relative parts.
You can use Graphics.DrawImage to draw a cropped image onto the graphics object from a bitmap.
Rectangle cropRect = new Rectangle(...);
Bitmap src = Image.FromFile(fileName) as Bitmap;
Bitmap target = new Bitmap(cropRect.Width, cropRect.Height);
using(Graphics g = Graphics.FromImage(target))
{
g.DrawImage(src, new Rectangle(0, 0, target.Width, target.Height),
cropRect,
GraphicsUnit.Pixel);
}
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
My knowledge is stored in sql server eg a sample of the data in the list view show like this, I wrote:
item.SubItems.Add(dr["Fname"].ToString ());
A statement that I wrote when I was on the field list, click on the text box was shown Vaio example:
Vfname.Text = e.Item.SubItems[1].Text;
It is not clear what you are trying to do, but I assume you should add Image objects to your List View, using System.Drawing.Image.FromFile(), then draw them calling Graphics.DrawImage, passing the image file you have in the listview.
http://msdn.microsoft.com/en-us/library/42807xh1(v=vs.110).aspx
Image newImage = Image.FromFile("SampImag.jpg");
// Create Point for upper-left corner of image.
Point ulCorner = new Point(100, 100);
// Draw image to screen.
e.Graphics.DrawImage(newImage, ulCorner);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I've created a form using Visual Studio 2010, using C#. I want to create and save a png picture of it (Form1.cs[design]).
Make a screenshot using the "Print key". Then copy the result into a program like Paint and click save. Save it as .png and you're done.
To sum the key combinations (Thanks to chris):
Print to take a picture of the whole screen
Alt + Print to screenshot the active window
WinKey http://pixelmonster.org/pool/windows_key_coloured.png + Print to make a screenshot and save it directly to %USERPROFILE%\Pictures\Screenshots\xxxx.png and gets automatically numbered (only working with Windows 8)
You can also use the Snipping Tool (just run SnippingTool from the Run dialog in Windows) which was firstly integrated in Windows Vista.
If you want to make this programatically you can use
Control.DrawToBitmap method.
Use Control.DrawToBitmap Method - http://msdn.microsoft.com/en-us/library/system.windows.forms.control.drawtobitmap.aspx
using (var bmp = new Bitmap(Width,Height))
{
DrawToBitmap(bmp, new Rectangle(0, 0, bmp.Width, bmp.Height));
bmp.Save(#"c:\temp\screenshot.png");
}