本文整理汇总了C#中System.Drawing.Image.GetFrameCount方法的典型用法代码示例。如果您正苦于以下问题:C# Image.GetFrameCount方法的具体用法?C# Image.GetFrameCount怎么用?C# Image.GetFrameCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Image
的用法示例。
在下文中一共展示了Image.GetFrameCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ImageAnimation
//-------------------------------------------------------------------------------
//
public ImageAnimation(Image img)
{
_image = img;
FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
MaxFrameCount = img.GetFrameCount(FrameDimension);
PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
FrameDelays = new int[MaxFrameCount];
for (int i = 0; i < MaxFrameCount; i++) {
FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
}
MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);
LoopInfinity = (MaxLoopCount == 0);
_timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
try {
_image.SelectActiveFrame(FrameDimension, 0);
}
catch (InvalidOperationException/* ex*/) {
//Log.DebugLog(ex);
//Debug.Assert(false, "Image.SelectActiveFrame失敗");
}
}
示例2: AnimatedImage
public AnimatedImage(Image Image)
{
gifImage = Image; //initialize
dimension = new FrameDimension(gifImage.FrameDimensionsList[0]); //gets the GUID
frameCount = gifImage.GetFrameCount(dimension); //total frames in the animation
_timer.Elapsed += new System.Timers.ElapsedEventHandler(_timer_Elapsed);
}
示例3: PagingImage
public PagingImage(string filename)
{
_filename = filename;
img = Bitmap.FromFile(filename);
_pages = img.GetFrameCount(FrameDimension.Page);
img.Dispose();
}
示例4: GifReader
/// <summary>
///
/// </summary>
/// <param name="stream"></param>
public GifReader(Stream stream)
{
_gifImage = Image.FromStream(stream); //initialize
_dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]); //gets the GUID
_frameCount = _gifImage.GetFrameCount(_dimension); //total frames in the animation
}
示例5: ImageInfo
/// <devdoc>
/// </devdoc>
public ImageInfo(Image image) {
this.image = image;
animated = ImageAnimator.CanAnimate(image);
if (animated) {
frameCount = image.GetFrameCount(FrameDimension.Time);
PropertyItem frameDelayItem = image.GetPropertyItem(PropertyTagFrameDelay);
// If the image does not have a frame delay, we just return 0.
//
if (frameDelayItem != null) {
// Convert the frame delay from byte[] to int
//
byte[] values = frameDelayItem.Value;
Debug.Assert(values.Length == 4 * FrameCount, "PropertyItem has invalid value byte array");
frameDelay = new int[FrameCount];
for (int i=0; i < FrameCount; ++i) {
frameDelay[i] = values[i * 4] + 256 * values[i * 4 + 1] + 256 * 256 * values[i * 4 + 2] + 256 * 256 * 256 * values[i * 4 + 3];
}
}
}
else {
frameCount = 1;
}
if (frameDelay == null) {
frameDelay = new int[FrameCount];
}
}
示例6: GifImage
public GifImage(Image path)
{
gifImage = path;
//initialize
dimension = new FrameDimension(gifImage.FrameDimensionsList[0]);
//gets the GUID
//total frames in the animation
frameCount = gifImage.GetFrameCount(dimension);
}
示例7: GifHandler
public GifHandler( Image Image ) {
mImage = Image.Clone() as Image;
mFrameDimension = new FrameDimension( mImage.FrameDimensionsList[ 0 ] );
mFrameCount = mImage.GetFrameCount( mFrameDimension );
mFrameTimes = new int[ mFrameCount ];
byte[] times = mImage.GetPropertyItem( 0x5100 ).Value;
for( int i = 0; i < mFrameCount; i++ )
mFrameTimes[ i ] = BitConverter.ToInt32( times, 4 * i ) * 10;
}
示例8: GifBox
private void GifBox(Image gif, PictureBox pic)
{
FrameDimension fd = new FrameDimension(gif.FrameDimensionsList[0]);
int count = gif.GetFrameCount(System.Drawing.Imaging.FrameDimension.Time);
for (int i = 0; i < count; i++)
{
gif.SelectActiveFrame(fd, i);
pic.Image = gif;
}
}
示例9: AnimateImage
/// <summary>
/// 实例化一个AnimateImage。
/// </summary>
/// <param name="img">动画图片。</param>
public AnimateImage(Image img) {
image = img;
lock (image) {
mCanAnimate = ImageAnimator.CanAnimate(image);
if (mCanAnimate) {
Guid[] guid = image.FrameDimensionsList;
frameDimension = new FrameDimension(guid[0]);
mFrameCount = image.GetFrameCount(frameDimension);
}
}
}
示例10: GifImage
public GifImage(string path)
{
_lastRequest = DateTime.Now;
_gifImage = Image.FromFile(path); //initialize
_dimension = new FrameDimension(_gifImage.FrameDimensionsList[0]); //gets the GUID
FrameCount = _gifImage.GetFrameCount(_dimension); //total frames in the animation
Source = path;
var item = _gifImage.GetPropertyItem(0x5100); // FrameDelay in libgdiplus
_delay = (item.Value[0] + item.Value[1]*256)*10; // Time is in 1/100th of a second
}
示例11: GifDecoder
/// <summary>
/// Initializes a new instance of the <see cref="GifDecoder"/> class.
/// </summary>
/// <param name="image">
/// The <see cref="Image"/> to decode.
/// </param>
public GifDecoder(Image image)
{
this.Height = image.Height;
this.Width = image.Width;
if (FormatUtilities.IsAnimated(image))
{
this.IsAnimated = true;
if (this.IsAnimated)
{
int frameCount = image.GetFrameCount(FrameDimension.Time);
int last = frameCount - 1;
double length = 0;
List<GifFrame> gifFrames = new List<GifFrame>();
// Get the times stored in the gif.
byte[] times = image.GetPropertyItem((int)ExifPropertyTag.FrameDelay).Value;
for (int i = 0; i < frameCount; i++)
{
// Convert each 4-byte chunk into an integer.
// GDI returns a single array with all delays, while Mono returns a different array for each frame.
TimeSpan delay = TimeSpan.FromMilliseconds(BitConverter.ToInt32(times, (4 * i) % times.Length) * 10);
// Find the frame
image.SelectActiveFrame(FrameDimension.Time, i);
Bitmap frame = new Bitmap(image);
frame.SetResolution(image.HorizontalResolution, image.VerticalResolution);
// TODO: Get positions.
gifFrames.Add(new GifFrame { Delay = delay, Image = frame });
// Reset the position.
if (i == last)
{
image.SelectActiveFrame(FrameDimension.Time, 0);
}
length += delay.TotalMilliseconds;
}
this.GifFrames = gifFrames;
this.AnimationLength = length;
// Loop info is stored at byte 20737.
this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
this.IsLooped = this.LoopCount != 1;
}
}
}
示例12: IsGIFAnimation
public static bool IsGIFAnimation(Image image)
{
System.Guid[] frameDimensionsList = image.FrameDimensionsList;
for (int i = 0; i < frameDimensionsList.Length; i++)
{
System.Guid guid = frameDimensionsList[i];
FrameDimension dimension = new FrameDimension(guid);
if (image.GetFrameCount(dimension) > 1)
{
return true;
}
}
return false;
}
示例13: GetStackImage
public static Bitmap GetStackImage(Image image, int count, Item item) {
if (image == null) return new Bitmap(item.image);
int max = image.GetFrameCount(FrameDimension.Time);
int index = 0;
if (count <= 5) index = count - 1;
else if (count <= 10) index = 5;
else if (count <= 25) index = 6;
else if (count <= 50) index = 7;
else index = 8;
if (index >= max) index = max - 1;
image.SelectActiveFrame(FrameDimension.Time, index);
return new Bitmap((Image)image.Clone());
}
示例14: GifDecoder
/// <summary>
/// Initializes a new instance of the <see cref="GifDecoder"/> class.
/// </summary>
/// <param name="image">
/// The <see cref="Image"/> to decode.
/// </param>
/// <param name="animationProcessMode">
/// The <see cref="AnimationProcessMode" /> to use.
/// </param>
public GifDecoder(Image image, AnimationProcessMode animationProcessMode)
{
this.Height = image.Height;
this.Width = image.Width;
if (FormatUtilities.IsAnimated(image) && animationProcessMode == AnimationProcessMode.All)
{
this.IsAnimated = true;
this.FrameCount = image.GetFrameCount(FrameDimension.Time);
// Loop info is stored at byte 20737.
this.LoopCount = BitConverter.ToInt16(image.GetPropertyItem((int)ExifPropertyTag.LoopCount).Value, 0);
}
else
{
this.FrameCount = 1;
}
}
示例15: ImageAnimation
//-------------------------------------------------------------------------------
//
public ImageAnimation(Image img)
{
_image = img;
FrameDimension = new FrameDimension(img.FrameDimensionsList[0]);
MaxFrameCount = img.GetFrameCount(FrameDimension);
PropertyItem pItemFrameDelay = img.GetPropertyItem(FRAME_DELAY);
PropertyItem pItemFrameNum = img.GetPropertyItem(FRAME_NUM);
FrameDelays = new int[MaxFrameCount];
for (int i = 0; i < MaxFrameCount; i++) {
FrameDelays[i] = BitConverter.ToInt32(pItemFrameDelay.Value, 4 * i);
}
MaxLoopCount = BitConverter.ToInt16(pItemFrameNum.Value, 0);
LoopInfinity = (MaxLoopCount == 0);
_timer = new Timer(Timer_Elapsed, null, Timeout.Infinite, Timeout.Infinite);
_image.SelectActiveFrame(FrameDimension, 0);
}