Pick a section of an image in c# - c#

I have an image with multiple portraits inside, how can I pick each one of them without cutting the image in photoshop or something like that. The image would be 8 images in row by 3 columns can I do this programatically? Links would help to learn about this topic, not looking for free code, I genuinly don't know how to google for this.
I know in Unity they use images like that for animations and I guess somehow loop through them. In my case I only need to pick one randomly.
I added unity tag because game developers might be more familiar with this.
If my title isn't great please free to edit it.
This is the image
thank you

You can import texture as multiple sprites. Select it in the project hierarchy and then select Multiple.
.
After that, you can click Sprite Editor to split the texture.
In my case, it sliced the picture like this:

Related

Unity sprite editor don't import Sprites

I have one really hard problem without any solution , I tried to update Unity on the newest version and the problem still persist. I don't know if i make any wrong setup of Unity Edit or I need to click something more to import sliced sprites.
My problem is when i upload picture in good quality and when i open up Sprite Editor in unity on the same image i try to do Automatic slice to get more objects from same image..
Something like this i put on settings
It slices everything correctly because i can press onto diffrent objects and see the borders , i click apply and when i press x if he as i click apply again. When Sprite Editor closes i don't get any sliced sprites into my project folder.
So, My question is How to import automatic sliced sprites from sprite editor to my project ?
Please help me it seems I am really dumb to find solution for this alone.
Thank you for your time on reading my post. I hope there is one expert who can help me with this problem.....
p.s. so i slice it like this I click slice, then i click apply and press X on window and i don't see any sprites in my folder....
Found the solution , Everything worked but i didn't know how to open more images , by clicking into image in my sprites on small arrow ->
It show me all the sprites sliced correctly.
Thank you everyone for your help.
Make sure the sprite type is set to "Multiple" and you set the filtering to Point.
This will allow the sprite to be split and expand in the inspector. You won't get multiple files.

Show multiple images in one picturebox

I am still very new to C# and I'm developing an application that holds all of my textures which are in a png format.
I am at a stage where I need to be able to show multiple textures within 1 picture box, could I ask how this is achieved?
you can do it by making array of images you want to show.
Consider this example and tutorial here to learn about it.

Need to use Tiled Map editor with Unity 4.3.4

I shifted to unity few weeks ago. I am developing a 2D platformer. For creating the maps I am using Tiled map editor from www.mapeditor.org . I have created a basic map. Included the tileSheet png and the .tmx file (saved as XML) in the Assets of the project. I am able to read the XML , that is all the gid's. But I don't know how to access a particular portion(tile) from the tileSheet corresponding to a gid.
I think for this I need to load sprite in the memory and select a tile (by specifying Height and width and coords) from texture memory to display it on screen. As given here :http://gamedevelopment.tutsplus.com/tutorials/parsing-and-rendering-tiled-tmx-format-maps-in-your-own-game-engine--gamedev-3104
but its for flash , how I can achieve same thing in Unity using C#. Notice the copyPixel stuff in the flash code. I thought I could use ReadPixels but it is used for reading from screen only not the texture memory.
Thanks.
If you're working in Windows then the Tiled2Unity Utility sounds like it will fit your needs. It exports Object Layers and was made with Unity 4.3 features in mind.
(Full disclosure: I'm the author of Tiled2Unity)
EDIT: Tiled2Unity is available for Mac users as well now. There is a command-line version for Linux users. (all free)
If you can describe more carefully your problem and what you are trying to do, maybe myself or someone can help you better, for example what exactly do you mean by "load a sprite into memory"? Or "select a tile"? Copying pixel data is SLOWWW, and hopefully you don't mean to be doing this in real time.
Here is my real advice though:
Have you checked out UTiled? It does tiled maps in 2D in Unity so I think it already does what you want and it's free.
There is also UniTMX... free.
There is also 'Tiled Tilemaps'... which is like $2.
I also built a system that can also do what I think you are trying to do (your link is broken, so I can't be sure).
The system I built is called 'Tiled to Unity' (you can search it in youtube to see if it does what you want). It allows you to attach gameObjects to tiles and have tile variants, and can do 3D tiles.
Anyway, trying to roll your own pipeline from Tiled into Unity is a ton of work, and with these tools available, I think it is almost certainly unnecessary... That's just imo.

How to create an interactive Map using Images

I have a couple of images that I would like to create an interactive map of in Silverlight and WPF. The pictures are of States and counties. I tried doing some search on how this is done but have not been able to find a good example on how to go about accomplishing this. So I would appreciate your help. Thanks in advance.
I was involved in creating a Xaml World map from scratch (below) and that alone took nearly a day for a stylised polygon version (no fine detail)....
I have since purchased a Wacom Bamboo tablet & stylus and found that to be about 5 times faster to work with compared with a mouse.
Quoting myself: "You import a map as a background image and use the pen tool to dot-to-dot trace around the country. Combine all those path segments into a single path. Then create a separate poly-path for each state (close them to allow for a fill)."
Once you create them you can name the individual country polygons and connect up mouse logic to make them all glow on mouse over or change colour on press etc.
Basically all the other stuff on that screen are user controls and custom controls. Work out the behaviour you want and create controls to suit your own needs.
In your instance you can use less accurate polygons as they will only be for hit-testing and highlighting and you will want to retain the actual map images under the polygons.

Animation effect in .NET?

Can someone point me to a C# open source implementaion with a simple image animations.
e.g. I feed the input image to animator, and the animation code produces a few dozen of images which if displayed sequentially looks like animation.
I am not something extremely fancy - a simple DirectX filter like animations would do.
You would be look for a sprite then? Microsoft has tutorials on this including:
http://msevents.microsoft.com/cui/WebCastEventDetails.aspx?culture=en-US&EventID=1032273446&CountryCode=US
and general graphics in C# here:
http://www.microsoft.com/events/series/msdnvisualcsharp.aspx?tab=webcasts
Hmmm... I'm not sure if this is what you want, but I've have created a library called Transitions that lets you animate most properties of UI controls easily. You could use it to move the position of pictures, transition between pictures or grow and shrink pictures. But I'm not sure that this is exactly the effects you're after? Anyway, if it's any help, my library is here:
http://code.google.com/p/dot-net-transitions/

Categories