资源简介
拼图小游戏的源代码,包含两种方式,适用于对应博客
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WindowsFormsDemo
{
public static class Helpers
{
///
/// 获取等比例缩放的图片(高宽不一致时获取最中间部分的图片)
///
///
///
///
///
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;
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-12-24 22:55 WindowsFormsDemo\
目录 0 2015-04-02 23:24 WindowsFormsDemo\WindowsFormsDemo\
文件 45322 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\1201394142-4.jpg
文件 202068 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\135204698.jpg
文件 176968 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\135204702.jpg
文件 187 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\App.config
文件 3090 2015-04-02 22:20 WindowsFormsDemo\WindowsFormsDemo\Helpers.cs
文件 541 2015-04-02 22:35 WindowsFormsDemo\WindowsFormsDemo\Program.cs
目录 0 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\Properties\
文件 1374 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\Properties\AssemblyInfo.cs
文件 2872 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\Properties\Resources.Designer.cs
文件 5817 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\Properties\Resources.resx
文件 1103 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\Properties\Settings.Designer.cs
文件 249 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\Properties\Settings.settings
文件 8687 2015-02-10 21:52 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm1.Designer.cs
文件 6094 2015-04-02 23:24 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm1.cs
文件 6193 2015-02-10 21:52 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm1.resx
文件 7361 2015-02-12 22:03 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm2.Designer.cs
文件 9010 2015-04-02 22:34 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm2.cs
文件 6020 2015-02-12 22:03 WindowsFormsDemo\WindowsFormsDemo\RandomPictureForm2.resx
文件 4703 2015-04-02 22:16 WindowsFormsDemo\WindowsFormsDemo\WindowsFormsDemo.csproj
目录 0 2015-02-10 21:38 WindowsFormsDemo\WindowsFormsDemo\bin\
目录 0 2015-04-03 07:28 WindowsFormsDemo\WindowsFormsDemo\bin\Debug\
目录 0 2015-04-03 07:28 WindowsFormsDemo\WindowsFormsDemo\bin\Release\
目录 0 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\obj\
目录 0 2015-04-03 07:28 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\
文件 1453 2014-12-26 21:40 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\DesignTimeResolveAssemblyReferences.cache
文件 7192 2015-04-02 22:14 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache
目录 0 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\TempPE\
文件 4608 2015-02-12 22:04 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll
文件 0 2014-12-24 22:55 WindowsFormsDemo\WindowsFormsDemo\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
............此处省略4个文件信息
相关资源
- Flash as3.0拼图游戏
- Flash as3.0制作的拼图小游戏源码。
- Authorware拼图游戏作品
- 简洁完整的flash拼图游戏AS3.0
- 一个flashas3.0的拼图游戏代码
- Flash拼图游戏源代码
- 基于IOS平台的游戏之小拼图
- 滑动拼图验证码
- 纯JS打造的滑块拼图验证
- Authorware拼图游戏源码
- qt5实现的一个拼图游戏
- 拼图游戏自动复原支持3乘3以上易语言
- flash+as3.0九宫格拼图游戏
- FLASH实现拼图游戏
- 拼图九宫格源代码
- 基于MFC的拼图游戏
- J2ME拼图游戏源代码
- 基于A*算法的3*3拼图
- 基于J2ME的简单拼图游戏
- 少儿编程:梦幻拼图小游戏源码(scr
- 拼图小游戏含源码
- QT拼图游戏
- js-canvas-拼图
- Unity3d制作简单拼图游戏源码+工程
- 拖拽方格到指定位置,html5+jquery.ui.
评论
共有 条评论