←Select platform

ValidateLines Method

Summary
Validates lines of an image that was added during a LoadImage event using the Append function.
Syntax
C#
Objective-C
C++/CLI
Python
public void ValidateLines( 
   int row, 
   int lines 
) 
- (BOOL)validateLines:(NSInteger)lines row:(NSInteger)row error:(NSError **)error; 
public: 
void ValidateLines(  
   int row, 
   int lines 
)  
def ValidateLines(self,row,lines): 

Parameters

row
Row number of the first line in the image to validate. In the LoadImage event, this corresponds to the first line in the buffer.

lines
Number of lines to validate. In the LoadImage event, this corresponds to the number of lines in the buffer.

Remarks

The Append method enables you to update an image in the LoadImage event, so that you can play an animation file as it is being loaded. The ValidateLines method lets you validate the lines that the animation playback engine will render to the target image.

If you pass null (Nothing in VisualBasic) in the animatedImage parameter for the RasterImageAnimator constructor, you can use the Append method to add frames to the multi-frame image during the animation. This is useful if you want to play an animated file as it is being loaded. If you need to reference the multi-frame image after the animation, you can call the Destroy method before you dispose this RasterImageAnimator object.

After you call Destroy, this RasterImageAnimator object is invalid and you should only call the Dispose method afterwards.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.Drawing; 
 
 
RasterImageAnimator _animator; 
RasterImage _targetImage; 
Graphics _graphics; 
LeadRect _destRect; 
RasterPaintProperties _paintProperties; 
 
 
public void RasterImageAppendExample(Panel panel) 
{ 
	// Initialize the RasterCodecs object 
	RasterCodecs codecs = new RasterCodecs(); 
 
	// An animated GIF file 
	string fileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye.gif"); 
 
	// load the first frame, so we have the palette and a target image for playback 
	_targetImage = codecs.Load(fileName, 0, CodecsLoadByteOrder.BgrOrGray, 1, 1); 
 
	// Create the animator 
	_animator = new RasterImageAnimator(_targetImage, null); 
 
	// Setup our class members used in the event handler 
	_graphics = panel.CreateGraphics(); 
	_destRect = LeadRect.FromLTRB(panel.ClientRectangle.Left, panel.ClientRectangle.Top, panel.ClientRectangle.Right, panel.ClientRectangle.Bottom); 
	_paintProperties = RasterPaintProperties.Default; 
	_paintProperties.PaintEngine = RasterPaintEngine.GdiPlus; 
 
	// Hook to the LoadImage event and load the file 
	codecs.LoadImage += new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
	codecs.Load(fileName); 
	codecs.LoadImage -= new EventHandler<CodecsLoadImageEventArgs>(Codecs_LoadImage); 
 
	_graphics.Dispose(); 
	_animator.Dispose(); 
	_animator = null; 
 
	_targetImage.Dispose(); 
 
	codecs.Dispose(); 
} 
 
void Codecs_LoadImage(object sender, CodecsLoadImageEventArgs e) 
{ 
	if ((e.Flags & CodecsLoadImageFlags.FirstRow) == CodecsLoadImageFlags.FirstRow) 
		_animator.Append(e.Image); 
 
	_animator.ValidateLines(e.Row, e.Lines); 
 
	RasterImageAnimatorState state = _animator.State; 
 
	while (state != RasterImageAnimatorState.End) 
	{ 
		state = _animator.Process(); 
 
		LeadRect updateRect; 
 
		switch (state) 
		{ 
			case RasterImageAnimatorState.WaitInput: 
				_animator.CancelWait(); 
				break; 
 
			case RasterImageAnimatorState.PostClear: 
			case RasterImageAnimatorState.PostRender: 
				updateRect = _animator.GetUpdateRectangle(true); 
				RasterImagePainter.Paint(_targetImage, _graphics, LeadRect.Empty, updateRect, _destRect, LeadRect.Empty, _paintProperties); 
				break; 
		} 
 
		break; 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 22.0.2023.5.16
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.