Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Drawing.Imaging;
- using System.Xml.Schema;
- namespace NPC_Creator
- {
- public partial class AnimationStation : Form
- {
- Bitmap image1; //Frames
- string systemName;
- int xframe = 16;
- int yframe = 32;
- public AnimationStation()
- {
- InitializeComponent();
- }
- public Rectangle GetTileArea(int tileIndex, int tileSize, int sheetWidth)
- {
- int x = tileIndex % sheetWidth;
- int y = tileIndex / sheetWidth;
- return new Rectangle(x * tileSize, y * tileSize, tileSize, tileSize);
- }
- private void AnimationStation_Load(object sender, EventArgs e)
- {
- systemName = scheduleStudio.importSystem;
- int xmin = (int)frameCount.Value * 16 - 1;
- if (xmin < 0)
- {
- xmin = 0;
- }
- int ymin = (int)frameCount.Value * 32 - 1;
- if (ymin < 0)
- {
- ymin = 0;
- }
- if (xmin > 48)
- {
- xmin = xmin / 4;
- }
- int xmaximum = xmin + 16;
- int ymaximum = ymin + 32;
- try
- {
- //Get Spritesheet
- image1 = new Bitmap(Environment.CurrentDirectory + $"\\Export\\[CP]{systemName}\\assets\\img\\spritesheet.png");
- Rectangle tileArea = this.GetTileArea(tileIndex: 0, tileSize: 16, sheetWidthInTiles: 4);
- Rectangle rect = new Rectangle(xmin, ymin, xmaximum, ymaximum);
- Bitmap spriteFrame = image1.Clone(rect, PixelFormat.DontCare);
- pictureBox1.Image = spriteFrame;
- }
- catch (Exception ex)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement