资源简介
用C#写的一个支持鼠标拖动拼图的拼图游戏软件。软件能自动对加载的图片进行分割,并打乱顺序后放置在不同的图片框中,用户使用鼠标拖动图片框中的图片进行拼图,还具备挑战计时功能,拼图成功或者挑战失败后,系统会自动进行提示。

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.Windows.Forms;
namespace MyAmeazingPuzzle
{
public static class Cut
{
///
/// 获取等比例缩放的图片(高宽不一致时获取最中间部分的图片)
///
///
///
///
///
public static Image AdjImageToFitSize(this Image fromImage int width int height)
{
Bitmap bitmap = new Bitmap(width height);
Graphics graphics = Graphics.FromImage(bitmap);
Point point = new Point(0 0);
Point point2 = new Point(width 0);
Point point3 = new Point(0 height);
Point[] destPoints = new Point[] { point point2 point3 };
Rectangle rect = GetImageRectangle(fromImage);
graphics.DrawImage(fromImage destPoints rect GraphicsUnit.Pixel);
Image image = Image.FromHbitmap(bitmap.GetHbitmap());
bitmap.Dispose();
graphics.Dispose();
return image;
}
private static Rectangle GetImageRectangle(Image fromImage)
{//居中位置获取
int x = 0;
int y = 0;
int height = fromImage.Height;
int width = fromImage.Width;
if (fromImage.Height > fromImage.Width)
{
height = fromImage.Width;
y = (fromImage.Height - fromImage.Width) / 2;
}
else
{
width = fromImage.Height;
x = (fromImage.Width - fromImage.Height) / 2;
}
return new Rectangle(x y width height);
}
///
/// 将图片切割成小图片图片顺序为先水平后垂直
///
///
///
///
///
public static Image[] SplitToSmallImages(this Image fromImage int cx int cy)
{
Image[] imgs = new Image[cx * cy];
int nWidth = fromImage.Width / cx;
int nHeight = fromImage.Height / cy;
Bitmap image = new Bitmap(nWidth nHeight);
Graphics graphics = Graphics.FromImage(image);
for (int i = 0; i < cy; i++)
{
for (int j = 0; j < cx; j++)
{
graphics.DrawImage(fromImage 0 0 new Rectangle(j * nWidth i * nHeight nWidth nHeight) GraphicsUnit.Pixel);
Image img = Image.FromHbitmap(image.GetHbitmap());
int idx = j + i * cx;
img.Tag = idx;
imgs[idx] = img;
}
}
return imgs;
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 70144 2018-01-23 15:07 myPuzzle\myPuzzle\.vs\myPuzzle\v15\.suo
文件 0 2018-01-03 14:13 myPuzzle\myPuzzle\.vs\myPuzzle\v15\Server\sqlite3\db.lock
文件 655360 2018-01-23 15:07 myPuzzle\myPuzzle\.vs\myPuzzle\v15\Server\sqlite3\storage.ide
文件 189 2018-01-03 14:13 myPuzzle\myPuzzle\myPuzzle\App.config
文件 187795 2017-12-26 21:47 myPuzzle\myPuzzle\myPuzzle\bin\Debug\0.jpg
文件 24940 2017-12-26 21:22 myPuzzle\myPuzzle\myPuzzle\bin\Debug\1.jpg
文件 35379 2017-12-26 21:22 myPuzzle\myPuzzle\myPuzzle\bin\Debug\2.jpg
文件 27807 2017-12-26 21:22 myPuzzle\myPuzzle\myPuzzle\bin\Debug\3.jpg
文件 207169 2017-12-26 21:23 myPuzzle\myPuzzle\myPuzzle\bin\Debug\4.jpg
文件 194821 2017-12-26 21:24 myPuzzle\myPuzzle\myPuzzle\bin\Debug\5.jpg
文件 191475 2017-12-26 21:24 myPuzzle\myPuzzle\myPuzzle\bin\Debug\6.jpg
文件 1013760 2018-01-23 14:38 myPuzzle\myPuzzle\myPuzzle\bin\Debug\MyAmeazingPuzzle.exe
文件 189 2018-01-03 14:13 myPuzzle\myPuzzle\myPuzzle\bin\Debug\MyAmeazingPuzzle.exe.config
文件 42496 2018-01-23 14:38 myPuzzle\myPuzzle\myPuzzle\bin\Debug\MyAmeazingPuzzle.pdb
文件 1734 2018-01-17 15:10 myPuzzle\myPuzzle\myPuzzle\ClassDiagram1.cd
文件 3118 2018-01-08 14:09 myPuzzle\myPuzzle\myPuzzle\Cut.cs
文件 12131 2018-01-08 15:03 myPuzzle\myPuzzle\myPuzzle\Form1.cs
文件 12498 2018-01-05 21:17 myPuzzle\myPuzzle\myPuzzle\Form1.Designer.cs
文件 108572 2018-01-05 21:17 myPuzzle\myPuzzle\myPuzzle\Form1.resx
文件 601 2018-01-08 15:47 myPuzzle\myPuzzle\myPuzzle\Form2.cs
文件 2594 2018-01-05 21:17 myPuzzle\myPuzzle\myPuzzle\Form2.Designer.cs
文件 107589 2018-01-05 21:17 myPuzzle\myPuzzle\myPuzzle\Form2.resx
文件 4492 2018-01-17 16:55 myPuzzle\myPuzzle\myPuzzle\myPuzzle.csproj
文件 1464 2018-01-04 23:26 myPuzzle\myPuzzle\myPuzzle\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7669 2018-01-22 23:53 myPuzzle\myPuzzle\myPuzzle\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
文件 42 2018-01-07 14:34 myPuzzle\myPuzzle\myPuzzle\obj\Debug\MyAmeazingPuzzle.csproj.CoreCompileInputs.cache
文件 2356 2018-01-04 23:31 myPuzzle\myPuzzle\myPuzzle\obj\Debug\MyAmeazingPuzzle.csproj.FileListAbsolute.txt
文件 1315 2018-01-07 13:53 myPuzzle\myPuzzle\myPuzzle\obj\Debug\MyAmeazingPuzzle.csproj.GenerateResource.Cache
文件 2384 2018-01-03 15:40 myPuzzle\myPuzzle\myPuzzle\obj\Debug\MyAmeazingPuzzle.csprojResolveAssemblyReference.cache
文件 1013760 2018-01-23 14:38 myPuzzle\myPuzzle\myPuzzle\obj\Debug\MyAmeazingPuzzle.exe
............此处省略37个文件信息
相关资源
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- Winform可视化打印模板设计工具含源码
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论