Windows Forms C#, Image editing [closed] - c#

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.

Related

HTML5 Capture Attribute on devices image get rotated [closed]

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.

How to split an image into 12 different custom shape in unity3D or c# [closed]

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);
}

How do i make a parallax background? C# Monogame? [closed]

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 searched everything on the internet but I cannot find a way to make a simple parallax background for my title screen.
In general, a way to show a horizontally repeating background that should work with any library capable of showing images:
image is a background image.
image2 is a second copy of the background.
On update:
// Move the background to the left.
image.x -= PerUpdateDeltaX;
// If the background is off the screen, move it back on.
// You can use modulo/remainder to do this better.
if (image.x < -image.width)
image.x = image.width;
// Put the second image to the right of the first.
image2.x = image.x + image.width;
To make this look good, the edges of the background image that touch need to be seamless.
Then, to make parallax (where there appear to me multiple layers moving in 3D), just add in a few more things:
Transparency.
More pairs of repeating background images, one pair for each layer of parallax.
Different PerUpdateDeltaX values for each layer. To look good, the higher/closer layers should move faster than lower layers.

How to display images in a list view? [closed]

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);

Save WinForm to PDF & print multipage WinForm [closed]

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.

Categories