公共LeadSizeAnimationGlobalSize {得到;集;}
@ property(原子,分配)LeadSize animationGlobalSize
AnimationGlobalSize#获取和设置(RasterImage)
一个LeadSize结构,表明全球规模的动画形象。默认值是0,0意思相同大小的图像
使用这个属性的值RasterImageAnimator类正确更新正确的目标图像的一部分。
GIF文件可以包含多个不同大小的帧。的AnimationGlobalSize属性包含的“全球”大小动画GIF图像。单个帧应该呈现在这个全球大小值的偏移AnimationOffset财产。
这个属性的值改变时,改变了事件将火RasterImageChangedFlags设置为RasterImageChangedFlags.AnimationProperties。
有关更多信息,请参考实现动画。
使用Leadtools;
使用Leadtools.Codecs;
使用Leadtools.ImageProcessing;
使用Leadtools.Drawing;
/ / WIN32 API
常量intLOGPIXELSY = 90;
[DllImport (“gdi32”)]
走读生静态intGetDeviceCaps (IntPtr hdc,intnIndex);
[DllImport (“kernel32”)]
走读生静态intMulDiv (intnNumber,intnNumerator,intnDenominator);
公共无效AnimatedGIFExample ()
{
/ /将包含4帧的GIF文件
常量intframeCount = 4;
/ /每一帧是128×128像素(GIF文件会有两倍大小)
常量intframeWidth = 128;
常量intframeHeight = 128;
/ /背景颜色
RasterColor[]背景色=
{
新RasterColor (0 xff 0 x00 0 x00),
新RasterColor (0 x00 0 xff 0 x00),
新RasterColor (0 x00 0 x00 0 xff),
新RasterColor (0 xff 0 xff 0 x00)
};
/ /前景颜色
RasterColor[]字体颜色=
{
新RasterColor (0 xff 0 xff 0 x00),
新RasterColor (0 xff 0 x00 0 x00),
新RasterColor (0 x00 0 xff 0 x00),
新RasterColor (0 xff 0 x00 0 x00)
};
/ /延迟毫秒
int[]延迟=
{
1000年,
1000年,
1000年,
1000年
};
/ /左和顶部,我们希望帧转移到每一个角落
LeadPoint[]抵消=
{
新LeadPoint (0, 0),
新LeadPoint (frameWidth, 0),
新LeadPoint (frameWidth frameHeight),
新frameHeight LeadPoint (0),
};
RasterImageAnimationDisposalMethod [] disposalMethod =
{
RasterImageAnimationDisposalMethod.RestoreBackground,
RasterImageAnimationDisposalMethod.RestoreBackground,
RasterImageAnimationDisposalMethod.RestoreBackground,
RasterImageAnimationDisposalMethod.RestoreBackground
};
RasterColor写成backgroundColor = RasterColor.FromKnownColor (RasterKnownColor.Yellow);
RasterImage图像=零;
字体字体=零;
StringFormat StringFormat =零;
/ /创建框架
为(int帧= 0;帧< frameCount;框架+ +)
{
RasterImage frameImage =新RasterImage (
RasterMemoryFlags.Conventional,
frameWidth,
frameHeight,
24日,
RasterByteOrder.Bgr,
RasterViewPerspective.BottomLeft,
零,
IntPtr.Zero,
0)
{
/ /设置帧的属性
AnimationDelay =延迟(帧),
AnimationOffset =抵消(帧),
AnimationDisposalMethod = disposalMethod(帧),
/ /背景是白色的
AnimationBackground =写成backgroundColor
};
/ /画框架在其表面的数量
IntPtr hdc = RasterImagePainter.CreateLeadDC (frameImage);
图g = Graphics.FromHdc (hdc);
矩形rc =新矩形(0,0,frameWidth frameHeight);
刷子刷=新SolidBrush (RasterColorConverter.ToColor(背景色(帧)));
g。FillRectangle(刷,rc);
brush.Dispose ();
如果(字体= =零)
{
intfontHeight = MulDiv(72年,GetDeviceCaps (hdc LOGPIXELSY), 72);
字体=新字体(“Consolas”,fontHeight);
stringFormat =新StringFormat
{
对齐= StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
}
字符串str =字符串.Format (“{0}”,框架+ 1);
刷=新SolidBrush (RasterColorConverter.ToColor(字体颜色(帧)));
g。细绳(str,字体、画笔、rc stringFormat);
brush.Dispose ();
g.Dispose ();
RasterImagePainter.DeleteLeadDC (hdc);
如果(图片= =零)
形象= frameImage;
其他的
image.AddPage (frameImage);
}
font.Dispose ();
stringFormat.Dispose ();
/ /设置全球形象属性
的形象。一个nimationGlobalSize =新LeadSize (frameWidth * 2, frameHeight * 2);
的形象。一个nimationGlobalLoop = 0;
的形象。一个nimationGlobalBackground = backgroundColor;
/ /图片转换为8位/像素
ColorResolutionCommand cmd =新ColorResolutionCommand (
ColorResolutionCommandMode.AllPages,
8日,
RasterByteOrder.Rgb,
RasterDitheringMethod.None,
ColorResolutionCommandPaletteFlags.Optimized,
零);
cmd.Run(图片);
RasterCodecs编解码器=新RasterCodecs ();
/ /设置GIF保存选项
RasterColor [] animationPalette = image.GetPalette ();
codecs.Options.Gif.Save.SetAnimationPalette (animationPalette);
codecs.Options.Gif.Save。UseAnimationPalette =真正的;
/ / GIF动画宽度和高度,循环和背景
/ /将自动从图像
/ /保存文件
字符串文件名= Path.Combine (LEAD_VARS.ImagesDir,“AnimatedGifFile.gif”);
编解码器。保存(形象,文件名,RasterImageFormat。Gif 8 1,形象。PageCount 1 CodecsSavePageMode.Overwrite);
image.Dispose ();
codecs.Dispose ();
}
静态类LEAD_VARS
{
公共常量字符串ImagesDir =@“C: \ LEADTOOLS22 \ Resources \图片”;
}
帮助收藏
光栅net|C API|c++类库|HTML5 JavaScript
文档net|C API|c++类库|HTML5 JavaScript
医疗net|C API|c++类库|HTML5 JavaScript
医疗Web查看器net
188宝金博怎么下载
支持的平台上
net, Java, Android和iOS / macOS组件
C / c++类库的API
HTML5 JavaScript库
你的邮件已经发送到支持!有人应该联系!如果你的问题是紧急请回到聊天。
聊天时间:
周一——周五,上午6点等
谢谢你的反馈!
请填写表单重新开始一个新的聊天。
所有代理目前离线。
聊天时间:
周一-周五
早上8:30 - 6点
联系我们请填写这张表格,我们将通过电子邮件联系你。