<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>GAFMEDIA</title>
	<atom:link href="http://blog.gafmediastudio.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gafmediastudio.com</link>
	<description>Software Development Blog</description>
	<lastBuildDate>Wed, 15 Dec 2010 16:09:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>AS3 &#8211; Extract size on Image file</title>
		<link>http://blog.gafmediastudio.com/2010/08/16/as3-extract-size-on-image-file/</link>
		<comments>http://blog.gafmediastudio.com/2010/08/16/as3-extract-size-on-image-file/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 10:38:35 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[AS3 Functions]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=439</guid>
		<description><![CDATA[Here is a function that retrieves the size of an image directly into the file. We just have to pass the file and its type parameter and return the size of the image as &#171;&#160;Rectangle&#160;&#187;. //------------------------------------------------------------------------------------------------------ // AS3/AIR Extract Image size on file // V 1.0 //------------------------------------------------------------------------------------------------------ public function GetImageSize(ImageFile : File, Type : String) [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a function that retrieves the size of an image directly into the file.<br />
We just have to pass the file and its type parameter and return the size of the image as &laquo;&nbsp;Rectangle&nbsp;&raquo;.</p>
<pre class="brush: as3; ">

//------------------------------------------------------------------------------------------------------
// AS3/AIR Extract Image size on file
// V 1.0
//------------------------------------------------------------------------------------------------------
public function GetImageSize(ImageFile : File, Type : String) : Rectangle {
	var Result    : Rectangle  = new Rectangle(0,0,0,0);
	var Bytes     : ByteArray  = new ByteArray();
	var ImgStream : FileStream = new FileStream();
	switch (Type){
		case &quot;bmp&quot; :
			Bytes.endian = Endian.LITTLE_ENDIAN;
			break;
		case &quot;jpg&quot;  :
		case &quot;jpe&quot;  :
		case &quot;jpeg&quot; :
		case &quot;png&quot;  :
		case &quot;gif&quot; :
        		Bytes.endian = Endian.BIG_ENDIAN;
        		break;
        }
	ImgStream.open(ImageFile, FileMode.READ);
	ImgStream.position = 0;
	ImgStream.readBytes(Bytes, 0, ImgStream.bytesAvailable );
	ImgStream.close();
	Bytes.position = 0;
	var ReadInt  : uint   = 0;
	var ReadByte : uint   = 0;
	switch (Type){
		case &quot;jpg&quot;  :
		case &quot;jpe&quot;  :
		case &quot;jpeg&quot; :
			ReadInt = Bytes.readUnsignedShort();
			if ( ReadInt == 0xFFD8 ){
				while(Bytes.position &lt; Bytes.length) {
					ReadByte = Bytes.readUnsignedByte();
					if(ReadByte == 0xFF) {
						ReadByte = Bytes.readUnsignedByte();
						if (ReadByte == 0xC0){
							Bytes.readUnsignedShort(); // Skip section length
							Bytes.readUnsignedByte();  // Skip bit depth
							Result.height = Bytes.readUnsignedShort();
							Result.width  = Bytes.readUnsignedShort();
							break;
						}
					}
				}
			}
			return Result;
        		break;
		case &quot;bmp&quot; :
        		Bytes.readUTFBytes(16);
			Result.width  = Bytes.readUnsignedInt();
			Result.height = Bytes.readUnsignedInt();
        		break;
		case &quot;png&quot; :
        		Bytes.readUTFBytes(16);
			Result.width  = Bytes.readUnsignedInt();
			Result.height = Bytes.readUnsignedInt();
        		break;
		case &quot;gif&quot; :
			var SGTC : int = 0;
			ReadInt = Bytes.readUnsignedInt();
			if (ReadInt == 0x47494638 ) {
				Bytes.readUnsignedShort(); 				// Skip 2 last chars &#039;7a&quot; or &quot;9a&quot;
				Bytes.readUnsignedShort();   				// Skip ScreenWidth
				Bytes.readUnsignedShort();   				// Skip ScreenHeight
				var HeaderFlags : int = Bytes.readUnsignedByte();   	// Get Flags
				Bytes.readUnsignedByte();   				// Skip Background Color Index
				Bytes.readUnsignedByte();   				// Skip Pixel Aspect Ratio

				if ( (HeaderFlags &amp; 0x1) &gt; 0 ) {
					HeaderFlags = (HeaderFlags &gt;&gt; 5 ) &amp; 0x07 ;
					SGTC = 3 * Math.pow(2,( HeaderFlags + 1));
					if ( ( Bytes.position + SGTC ) &lt; Bytes.length){
						Bytes.position = Bytes.position + SGTC;
					} else {
						break;
					}
				}
				while(Bytes.position &lt; Bytes.length) {
					ReadByte = Bytes.readUnsignedByte();
					if ( ReadByte == 0x2C ){
						Bytes.readUnsignedShort();   // Skip Left
						Bytes.readUnsignedShort();   // Skip Top
						Result.width  = Bytes.readUnsignedByte() + 256 * Bytes.readUnsignedByte();
	 					Result.height = Bytes.readUnsignedByte() + 256 * Bytes.readUnsignedByte();
	 					break;
					} else if ( ReadByte == 0x21 ){
						while(Bytes.position &lt; Bytes.length) {
							ReadByte = Bytes.readUnsignedByte();
							if ( ReadByte == 0x00 ) break; // Search Block Terminator
						}
					}
				}
			}
        		break;
        }
        return Result;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/08/16/as3-extract-size-on-image-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3 – Image detection with unknow file type extention.</title>
		<link>http://blog.gafmediastudio.com/2010/08/16/as3-image-detection-with-unknow-file-type-extention/</link>
		<comments>http://blog.gafmediastudio.com/2010/08/16/as3-image-detection-with-unknow-file-type-extention/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 10:25:05 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[AS3 Functions]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=436</guid>
		<description><![CDATA[Here is a function wich check if a file is an image or not. The file type is determined following the signing of the header. //------------------------------------------------------------------------------------------------------ // AS3/AIR Image detection with unknow file type extention. // V 1.0 //------------------------------------------------------------------------------------------------------ public function GetImageFileType(TestFile : File) : String { var extention : String = &#34;&#34;; var Bytes [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a function wich check if a file is an image or not.<br />
The file type is determined following the signing of the header.</p>
<pre class="brush: as3; ">

//------------------------------------------------------------------------------------------------------
// AS3/AIR Image detection with unknow file type extention.
// V 1.0
//------------------------------------------------------------------------------------------------------
public function GetImageFileType(TestFile : File) : String {
	var extention : String     = &quot;&quot;;
        var Bytes     : ByteArray  = new ByteArray();
	var BmpStream : FileStream = new FileStream();
	Bytes.endian = Endian.LITTLE_ENDIAN;
	BmpStream.open(TestFile, FileMode.READ);
	BmpStream.position = 0;
	BmpStream.readBytes(Bytes, 0, 8 );
	BmpStream.close();
	//-------------------------------------------------------
	var signature : int = Bytes.readShort();
	if (signature == 0x4D42) {
		extention = &quot;bmp&quot;;
	} else {
		Bytes.position = 0;
		signature = Bytes.readInt()&amp; 0xFFFFFF;
		if (signature == 0xFFD8FF) {
			extention = &quot;jpg&quot;;
		} else {
			Bytes.position = 0;
			signature = Bytes.readInt()&amp; 0xFFFFFFFF;
			if (signature == 0x38464947  ) {
				extention = &quot;gif&quot;;
			} else {
				Bytes.position = 0;
				signature = Bytes.readInt();
				if (signature == 0x474E5089 ) {
					signature = Bytes.readInt();
					if (signature == 0x0A1A0A0D ) {
						extention = &quot;png&quot;;
					}
				}
			}
		}
	}
        return extention;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/08/16/as3-image-detection-with-unknow-file-type-extention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Objective-C : Draw a Pie Chart with iPhone / iPod / iPad</title>
		<link>http://blog.gafmediastudio.com/2010/07/02/draw-a-pie-chart-with-iphone-ipod-ipad/</link>
		<comments>http://blog.gafmediastudio.com/2010/07/02/draw-a-pie-chart-with-iphone-ipod-ipad/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 13:06:31 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Class]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[Objective-c]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=401</guid>
		<description><![CDATA[After developing LinkLite for iPhone, I decided to share with you my experience in this area by publishing the Objective-c class used to draw a pie chart. This time I would not give you that code snippets to make a pie chart, this being due to the specificity of the goal. A view of result [...]]]></description>
			<content:encoded><![CDATA[<p>After developing <a href="http://linklite.gafmediastudio.com/" target="_blank">LinkLite</a> for iPhone, I decided to share with you my experience in this area by publishing the Objective-c class used to draw a pie chart. This time I would not give you that code snippets to make a pie chart, this being due to the specificity of the goal.</p>
<p>A view of result :<br />
<a href="http://blog.gafmediastudio.com/?attachment_id=425"><img src="http://blog.gafmediastudio.com/wp-content/uploads/iphone_piechart-150x150.png" alt="" title="iphone_piechart" width="150" height="150" class="aligncenter size-thumbnail wp-image-425" /></a></p>
<p>Preliminary :<br />
To make a pie must first have data to display, and perform an array dedicated to the creation of the pie.</p>
<p>First look at the type of data contained in your array, it could be for example:</p>
<pre class="brush: c++; ">

//
//  Class_Item.h
//
@interface Your_Array_Item : NSObject {
	NSString* time;
	NSString* ip;
	NSString* system;
	NSString* browser;
	NSString* version;
	NSString* resolution;
	NSString* language;
	NSString* referer;
	NSString* isp;
}

@property (nonatomic, retain) NSString* time;
@property (nonatomic, retain) NSString* ip;
@property (nonatomic, retain) NSString* system;
@property (nonatomic, retain) NSString* browser;
@property (nonatomic, retain) NSString* version;
@property (nonatomic, retain) NSString* resolution;
@property (nonatomic, retain) NSString* language;
@property (nonatomic, retain) NSString* referer;
@property (nonatomic, retain) NSString* isp;

@end

//
//  Class_Item.m
//
#import &quot;Class_Item.h&quot;
@implementation Your_Array_Item
@synthesize time;
@synthesize ip;
@synthesize system;
@synthesize browser;
@synthesize version;
@synthesize resolution;
@synthesize language;
@synthesize referer;
@synthesize isp;
@end
</pre>
<p>Then look at the type of data contained in our array for display:</p>
<pre class="brush: c++; ">

//
//  Class_Array_Item.h
//
@interface Array_Item_To_Show: NSObject {
	NSString* Info;      // Title of the pie part
	UIColor*  Color;     // Color of the pie part
	double    Percent;   // percent of the pie part ( 0.33 =&gt; 33% )
	double    CountItem; // the number of similare item found, this number is for percent calculation
}

@property (nonatomic, retain) NSString* Info;
@property (nonatomic, retain) UIColor*  Color;
@property double  Percent;
@property double  CountItem;
@end

//
//  Class_Array_Item.m
//
#import &quot;Class_Array_Item.h&quot;
@implementation Array_Item_To_Show
@synthesize Info;
@synthesize Color;
@synthesize Percent;
@synthesize CountItem;
@end
</pre>
<p>In your view controller (or other) you must define this</p>
<pre class="brush: c; ">

@interface YourViewController : UIViewController {
...
NSMutableArray*  YourDataArray; // Your data array
NSMutableArray*  PieItemArray;  // Array of Array_Item_To_Show
...
}
</pre>
<p>and initialize to avoid exeption !</p>
<pre class="brush: c++; ">

- (void) viewDidLoad {
...
YourDataArray = [[NSMutableArray arrayWithCapacity:0] retain];
PieItemArray  = [[NSMutableArray arrayWithCapacity:0] retain];
...
}
</pre>
<p>To convert YourDataArray to PieItemArray you can write this fuction</p>
<pre class="brush: c++; ">

//------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------
- (UIColor*) GetRandomColor
{
	CGFloat red   = (CGFloat)random()/(CGFloat)RAND_MAX;
	CGFloat blue  = (CGFloat)random()/(CGFloat)RAND_MAX;
	CGFloat green = (CGFloat)random()/(CGFloat)RAND_MAX;
	return [UIColor colorWithRed: red green: green blue: blue alpha: 1.0];
}
//------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------
- (BOOL) CheckIfExistInArray : (NSArray*) Array : (NSString*) Search
{
	for (int i=0; i &lt; Array.count; i++){
		Array_Item_To_Show* Item = [Array objectAtIndex:i];
		if ( [Item.Info isEqualToString: Search] ){
			[[Array objectAtIndex:i] setCountItem: [[Array objectAtIndex:i] CountItem] + 1];
			return YES;
		}
	}
	return NO;
}
//------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------
- (void) GetFinalArray : (NSString*) ItemFieldName
{
	int i;

	//--------------------------------------------------------------------------
	// declaration of new temp array for result
	NSMutableArray* TmpArray = [[NSMutableArray arrayWithCapacity:0] retain];

	//--------------------------------------------------------------------------
	// declaration of your array count item
	int ArrayCountValue = DataArray.count;

	//--------------------------------------------------------------------------
	// declaration of Temp item to add in TmpArray
	Array_Item_To_Show* NewItem;

	//--------------------------------------------------------------------------
	// declaration of your array item type
	Your_Array_Item* YourArrayItem;

	//--------------------------------------------------------------------------
	// declaration of Percent number
	NSNumber* Percent;

	//--------------------------------------------------------------------------
	// get all symilarity item and count
	//--------------------------------------------------------------------------
	for (i = 0; i &lt; ArrayCountValue; i++){
		YourArrayItem = [YourDataArray objectAtIndex:i];

		if ( [self CheckIfExistInArray: TmpArray : [YourArrayItem valueForKey: ItemFieldName] ] == NO ){

			//--------------------------------------------------------------------------
			// add item if not exists !
			NewItem = [Array_Item_To_Show alloc];
			[NewItem setInfo: [YourArrayItem valueForKey:ItemFieldName] ];
			[NewItem setCountItem: 1];
			[TmpArray addObject: NewItem];
		}
	}
	//--------------------------------------------------------------------------
	// Compute percent for each items
	//--------------------------------------------------------------------------
	for (i=0; i &lt; TmpArray.count; i++){
		NewItem = [TmpArray objectAtIndex:i];
		Percent = [NSNumber numberWithFloat:( 360 * (NewItem.CountItem / ArrayCountValue) )];

		//--------------------------------------------------------------------------
		// Assign a percent to pie part
		[NewItem setPercent: [Percent floatValue]];

		//--------------------------------------------------------------------------
		// Assign a color to pie part
		[NewItem setColor: [self GetRandomColor]];
	}
	//--------------------------------------------------------------------------
	// empty the final array that contain result
	[PieItemArray removeAllObjects];

	//--------------------------------------------------------------------------
	// Sort result array by percent
	NSSortDescriptor* Descriptor = [[[NSSortDescriptor alloc] initWithKey:@&quot;Percent&quot; ascending: NO] autorelease];

	//--------------------------------------------------------------------------
	// finally fill the final array with the sorted temp array
	[PieItemArray addObjectsFromArray: [TmpArray sortedArrayUsingDescriptors:[NSArray arrayWithObject: Descriptor]]];
}
</pre>
<p>The function to draw a pie chart with PieItemArray is show bellow :</p>
<pre class="brush: c++; ">

//------------------------------------------------------------------------------------
//
//------------------------------------------------------------------------------------
- (UIImage*) DrawPieWithArray : (CGFloat) PieRadius : (CGFloat) TopLeftBorder
{
	CGFloat CenterX   = PieRadius + TopLeftBorder;
	CGFloat CenterY   = PieRadius + TopLeftBorder;
	CGFloat StartRad  = 0;
	CGFloat EndRad    = 0;
	//---------------------------------------------------------------------------------------
	CGColorSpaceRef _ColorSpace  = CGColorSpaceCreateDeviceRGB();
	CGContextRef    _ViewContext = CGBitmapContextCreate (NULL,  2*CenterX, 2*CenterY, 8, 0, _ColorSpace, kCGImageAlphaPremultipliedLast);
	if (_ViewContext == NULL){
		CGColorSpaceRelease(_ColorSpace);
		return nil;
	}
	//---------------------------------------------------------------------------------------
	CGContextSetRGBStrokeColor(_ViewContext, 1.0, 1.0, 1.0, 1.0);
	CGContextSetLineWidth(_ViewContext, 4.0);
	//---------------------------------------------------------------------------------------
	for (NSUInteger i = 0; i&lt; PieItemArray.count; i++){
		Array_Item_To_Show* Item = [PieItemArray objectAtIndex:i];

		//-------------------------------------------------------------
		// set the pie part color
		const CGFloat* RGBComponents = CGColorGetComponents( [Item.Color CGColor] );
		CGContextSetRGBFillColor(_ViewContext, RGBComponents[0], RGBComponents[1], RGBComponents[2], 1.0 );

		//-------------------------------------------------------------
		// Compute the finale angle for the pie part arc
		EndRad = StartRad + Item.Percent;

		//-------------------------------------------------------------
		// draw the pie part
		CGContextMoveToPoint(_ViewContext, CenterX, CenterY);
		CGContextAddArc(_ViewContext, CenterX, CenterY, PieRadius,  radians(StartRad), radians(EndRad), 0);
		CGContextClosePath(_ViewContext);
		CGContextFillPath(_ViewContext);

		StartRad = EndRad;
	}

	//--------------------------------------------------------------------------------------
	// Option : to improve rendering, you can add an overlay image on the top of the pie
	// See bellow for image example.
	CGImageRef OverlayImage = [[UIImage imageNamed: @&quot;cam_overlay.png&quot; ] CGImage];
	CGContextDrawImage(_ViewContext, CGRectMake( 0.0,  0.0, CGImageGetWidth(OverlayImage), CGImageGetHeight(OverlayImage) ), OverlayImage);	

	//---------------------------------------------------------------------------------------
	// Create UIImage with context
	CGImageRef _BitmapContext = CGBitmapContextCreateImage(_ViewContext);
	UIImage* Result           = [UIImage imageWithCGImage: _BitmapContext];

	//---------------------------------------------------------------------------------------
	// free all resource !
	CGContextRelease(_ViewContext);
	CGColorSpaceRelease(_ColorSpace);
	CGImageRelease(_BitmapContext);
	return Result;
}
</pre>
<p>Bellow an example of overlay image used with LinkLite :<br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/cam_overlay.png" alt="Overlay Image" /></p>
<p>Finally to get a visual result you must :</p>
<p>1 &#8211; Fill your DataArray</p>
<p>2 &#8211; Call &laquo;&nbsp;GetFinalArray&nbsp;&raquo; function like this to show a pie chart with browser item for example !</p>
<pre class="brush: c++; ">

[self GetFinalArray : @&quot;browser&quot;];
</pre>
<p>3 &#8211; Call &laquo;&nbsp;DrawPieWithArray&nbsp;&raquo; function and fill your image with the result</p>
<pre class="brush: c++; ">

[your_Pie_img  setImage: [self DrawPieWithArray : 60.0 : 6.0]];
</pre>
<p>Now you are ready to show pie chart on your iPhone / iPad / iPod ! <img src='http://blog.gafmediastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/07/02/draw-a-pie-chart-with-iphone-ipod-ipad/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WhatYouTake : Similarity Image Reconition AIR Application</title>
		<link>http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/</link>
		<comments>http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/#comments</comments>
		<pubDate>Thu, 20 May 2010 11:54:25 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Application AIR]]></category>
		<category><![CDATA[Graphic]]></category>
		<category><![CDATA[Image]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>
		<category><![CDATA[Graphisme]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=360</guid>
		<description><![CDATA[Some time ago, I began to do an advanced image editor to organize and eliminate all duplicate images that might exist from my hard drive. The result is that AIR application with comparing and grouping similar image algorithm, for freeing the place that I miss so much. This application has a lot of options, which [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I began to do an advanced image editor to organize and eliminate all duplicate images that might exist from my hard drive.<br />
The result is that AIR application with comparing and grouping similar image algorithm, for freeing the place that I miss so much.<br />
This application has a lot of options, which would take too long to explain here, but basically, it consists of an organizer with notebook, an advanced slide-show, a graphics editor, and more, all in one.</p>
<p>Some screenshots:</p>
<table width="616" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/whatyoutake_snap1/" rel="attachment wp-att-367"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/WhatYouTake_Snap1-150x150.jpg" title="WhatYouTake_Snap1" width="150" height="150" class="aligncenter size-thumbnail wp-image-367"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/whatyoutake_snap2/" rel="attachment wp-att-366"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/WhatYouTake_Snap2-150x150.jpg" title="WhatYouTake_Snap2" width="150" height="150" class="aligncenter size-thumbnail wp-image-366"/><br />
</a>
</td>
</tr>
</table>
<p>Unfortunately, this application has not been completed but is functional, so if you introduce the courage to finish it, it will gladly, I&#8217;ll post the update here! <img src='http://blog.gafmediastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>You can download the application and the sources here:</p>
<p><a href='http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/whatyoutake_source/' rel='attachment wp-att-372'>WhatYouTake Source</a><br />
<a href='http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/whatyoutake_air/' rel='attachment wp-att-371'>WhatYouTake Air</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/05/20/similarity-image-reconition-air-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WyS: Wysiwyg editor for PDF.</title>
		<link>http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/</link>
		<comments>http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 16:11:11 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Application AIR]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=266</guid>
		<description><![CDATA[Here is one of the first applications that we had done in Flex &#8211; AIR, in order to test its possibilities. WhatYouSee is a Wysiwyg editor (What You See Is What You Get!) to generate a PDF file. This application also have an image editor. This application uses largely an excellent AS3 class developed by [...]]]></description>
			<content:encoded><![CDATA[<p>Here is one of the first applications that we had done in Flex &#8211; AIR, in order to test its possibilities.</p>
<p>WhatYouSee is a Wysiwyg editor (What You See Is What You Get!) to generate a PDF file. This application also have an image editor.<br />
This application uses largely an excellent AS3 class developed by <a href="http://alivepdf.bytearray.org/?page_id=5">bytearray.org</a>: alivepdf.</p>
<p>Some screenshots:</p>
<table border="0" cellspacing="0" cellpadding="0" width="616" align="center">
<tr>
<td width="154" valign="top">
<a rel="attachment wp-att-267" href="http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/whatyousee_snap1/"><br />
<img class="aligncenter size-thumbnail wp-image-267" title="WhatYouSee_Snap1" src="http://blog.gafmediastudio.com/wp-content/uploads/WhatYouSee_Snap1-150x150.jpg" width="150" height="150"/><br />
</a>
</td>
<td width="154" valign="top">
<a rel="attachment wp-att-268" href="http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/whatyousee_snap2/"><br />
<img class="aligncenter size-thumbnail wp-image-268" title="WhatYouSee_Snap2" src="http://blog.gafmediastudio.com/wp-content/uploads/WhatYouSee_Snap2-150x150.jpg" width="150" height="150"/><br />
</a>
</td>
</tr>
</table>
<p>Unfortunately, this application has not been completed, so if you introduce the courage to finish it, it will gladly, I&#8217;ll post the update here! <img src='http://blog.gafmediastudio.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
You can download the application and the sources here:</p>
<p><a rel="attachment wp-att-269" href="http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/whatyousee_source/">WhatYouSee AS3 Source</a><br />
<a rel="attachment wp-att-270" href="http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/whatyousee_air/">WhatYouSee AIR Application</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/04/08/wys-wysiwyg-editor-for-pdf/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MagicToolbox, AIR-AS3 plugins manager.</title>
		<link>http://blog.gafmediastudio.com/2010/04/05/magictoolbox-air-as3-plugins-manager/</link>
		<comments>http://blog.gafmediastudio.com/2010/04/05/magictoolbox-air-as3-plugins-manager/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 07:13:23 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Application AIR]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=243</guid>
		<description><![CDATA[Here is one of the first applications that we made in Flex &#8211; AIR, in order to test its possibilities. MagicToolbox, is a management interface for plugins, specifically it use AS3 &#171;&#160;IModuleInterface&#160;&#187; for module communication. Some screenshots: It would take too long to explain the principle in detail, however small diagram below gives you an [...]]]></description>
			<content:encoded><![CDATA[<p>Here is one of the first applications that we made in Flex &#8211; AIR, in order to test its possibilities.<br />
MagicToolbox, is a management interface for plugins, specifically it use AS3 &laquo;&nbsp;IModuleInterface&nbsp;&raquo; for module communication.</p>
<p>Some screenshots:</p>
<table width="616" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/?attachment_id=246" rel="attachment wp-att-246"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/MagicToolbox_Snap1-150x150.jpg" title="MagicToolbox_Snap1" width="150" height="150" class="aligncenter size-thumbnail wp-image-246"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/?attachment_id=247" rel="attachment wp-att-247"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/MagicToolbox_Snap2-150x150.jpg" title="MagicToolbox_Snap2" width="150" height="150" class="aligncenter size-thumbnail wp-image-247"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/?attachment_id=245" rel="attachment wp-att-245"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/MagicToolbox_Snap3-150x150.jpg" title="MagicToolbox_Snap3" width="150" height="150" class="aligncenter size-thumbnail wp-image-245"/><br />
</a>
</td>
</tr>
</table>
<p>It would take too long to explain the principle in detail, however small diagram below gives you an idea of its operation.<br />
Note that all modules have common methods (the principle of the plugin) called by the main application:<br />
<a href="http://blog.gafmediastudio.com/?attachment_id=263" rel="attachment wp-att-263"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/MagicToolbox_Interface-150x150.png" title="MagicToolbox_Interface" width="150" height="150" class="aligncenter size-thumbnail wp-image-263"/><br />
</a></p>
<p>For all modules and script:</p>
<p><strong>getModuleInfo : </strong></p>
<p>Method returning the parameters of the plugin configuration form of XML:</p>
<ul>
<li>&laquo;&nbsp;IsMainModule&nbsp;&raquo; : Indicates whether this is the main module</li>
<li>&laquo;&nbsp;MinHeight&nbsp;&raquo; : Minimum height for the interface</li>
<li>&laquo;&nbsp;MinWidth&nbsp;&raquo; : Minimum width for the interface</li>
<li>&laquo;&nbsp;Resizable&nbsp;&raquo; : True or False if the interface is resizable</li>
<li>&laquo;&nbsp;HasDrawer&nbsp;&raquo; : If the interface has a drawer options</li>
<li>&laquo;&nbsp;DrawerName&nbsp;&raquo; : If HasDrawer = true, the name of the module options</li>
</ul>
<p>or null if there is a &laquo;&nbsp;script background&nbsp;&raquo;!</p>
<p><strong>getModuleReady :</strong><br />
	Returns True or False if the module to be initialized finished and ready for use.</p>
<p><strong>ExecuteCommand :</strong></p>
<ul>
<li>Command: String (Command Name)</li>
<li>Data : Object (parameters)</li>
</ul>
<p>The icing on the cake: We&#8217;ve added the ability to run a background script if the module does not run !</p>
<p>You can download the sources here :<br />
<a href='http://blog.gafmediastudio.com/?attachment_id=254' rel='attachment wp-att-254'>MagicToolbox Source</a><br />
<a href='http://blog.gafmediastudio.com/?attachment_id=257' rel='attachment wp-att-257'>MagicToolbox AIR</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/04/05/magictoolbox-air-as3-plugins-manager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Server for graphic web page capture.</title>
		<link>http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/</link>
		<comments>http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 15:59:01 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Application Delphi]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[Application]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Delphi]]></category>
		<category><![CDATA[Pascal]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.gafmediastudio.com/?p=198</guid>
		<description><![CDATA[Some time ago, I began to develop an http server providing catch graphic web page. Not having had the benefit of these programs, I decided to post on this blog, hoping that this work will help you. This is a first draft functional, but nevertheless deserves to be better, so if you have any updates, [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago, I began to develop an http server providing catch graphic web page.<br />
Not having had the benefit of these programs, I decided to post on this blog, hoping that this work will help you.<br />
This is a first draft functional, but nevertheless deserves to be better, so if you have any updates, be sure to join me, I&#8217;ll post them here.</p>
<p>The principle is very simple, the system consists of two distinct parts:</p>
<ul>
<li> Server for graphic web page capture (written in Delphi and based on Internet Explorer activeX). </li>
<li> browser (to facilitate testing I wrote a client in Flex-AIR to automate the server protocol). </li>
<p></Ul></p>
<h1><strong> The server:</strong></h1>
<p>After you learn the IP and port used, simply start the server, and that&#8217;s all. The other parameters are there to fix more precisely how it works.<br />
However, I have included the ability to retouch coarsely catches.</p>
<p>Some screenshots:</p>
<table width="616" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_snap1/" rel="attachment wp-att-207"><br />
<Img src="http://blog.gafmediastudio.com/wp-content/uploads/ScreenshotServer_Snap1-150x150.jpg" title="ScreenshotServer_Snap1" width="150" height="150" class="aligncenter size-thumbnail wp-image-207"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_snap2/" rel="attachment wp-att-208"><br />
<Img src="http://blog.gafmediastudio.com/wp-content/uploads/ScreenshotServer_Snap2-150x150.jpg" title="ScreenshotServer_Snap2" width="150" height="150" class="aligncenter size-thumbnail wp-image-208"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_snap3/" rel="attachment wp-att-209"><br />
<Img src="http://blog.gafmediastudio.com/wp-content/uploads/ScreenshotServer_Snap3-150x150.jpg" title="ScreenshotServer_Snap3" width="150" height="150" class="aligncenter size-thumbnail wp-image-209"/><br />
</a>
</td>
<td width="154" valign="top">
<a href="http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_snap4/" rel="attachment wp-att-210"><br />
<Img src="http://blog.gafmediastudio.com/wp-content/uploads/ScreenshotServer_Snap4-150x150.jpg" title="ScreenshotServer_Snap4" width="150" height="150" class="aligncenter size-thumbnail wp-image-210"/><br />
</a>
</td>
</tr>
</table>
<h1><strong>Web browser: </strong></h1>
<p>For a snapshot from the server, there are three things to do: </p>
<h2><strong>1 / Create a query capture :</strong></h2>
<p>To do this, simply call with your favorite browser, this type of application:<br />
http://YourIP:YourPort/index.html?Action=SetCapture&#038;Url=http://www.free.fr &#038;SrcWidth=953&#038;SrcHeight=1235&#038;Static=true&#038;CaptureDelay=0&#038; …<br />
<strong>To Server :</strong><br />
&#8216;Action&#8217; = &#8216;SetCapture&#8217; => Needed<br />
&#8216;Url&#8217; => String of Url to capture => Needed<br />
&#8216;SrcWidth&#8217; => Integer : Width of original Web page  => Needed<br />
&#8216;SrcHeight&#8217; => Integer : Height of original Web page => Needed<br />
&#8216;Static&#8217; => Boolean (&#8216;true’ or &#8216;false&#8217;) => Default = true<br />
&#8216;EmptyCache&#8217; => Boolean (&#8216;true’ or &#8216;false&#8217;) => Default = true<br />
if Static = false<br />
&#8216;CaptureDelay&#8217; => Integer : Delay before screenshot after page completed => Default = 0<br />
&#8216;OffsetTop&#8217; => Integer => Default = 0<br />
&#8216;OffsetLeft&#8217; => Integer => Default = 0<br />
&#8216;OffsetBottom&#8217; => Integer => Default = 0<br />
&#8216;OffsetRight&#8217; => Integer => Default = 0<br />
&#8216;Quality&#8217; => Integer => Default = 75 (%)<br />
&#8216;Zoom&#8217; => Decimal : Zoom factor (0.1..500) => Default = 1<br />
<strong>From Server :</strong><br />
xml =&gt; &lt;result&gt;&lt;action&gt;SetCapture&lt;/action&gt;&lt;data&gt;D1B831BF76B56038A6B0ADD3DDD663BA&lt;/data&gt;&lt;/result&gt;</p>
<p>&laquo;&nbsp;D1B831BF76B56038A6B0ADD3DDD663BA&nbsp;&raquo; is a single value returned by the server, used to identify your request.</p>
<h2><strong>2 / Ensure that the catch has been made :</strong></h2>
<p>To do this simply call, this request containing the ID provided by the first query:</p>
<p>http://YourIP:YourPort/index.html?Action=IsCaptureReady&#038;Id=D1B831BF76B56038A6B0ADD3DDD663BA</p>
<p><strong>To Server : </strong><br />
&#8216;Action&#8217; = &#8216;IsCaptureReady&#8217;<br />
&#8216;Id&#8217; => String => Needed<br />
<strong>From Server : </strong><br />
xml =&gt; &lt;result&gt;&lt;action&gt;IsCaptureReady&lt;/action&gt;&lt;data&gt;(&#8216;true’or &#8216;false&#8217;)&lt;/data&gt;&lt;/result&gt;</p>
<h2><strong>3 /Finally, if the answer is positive, download the image with the following query :</strong></h2>
<p>http://YourIP:YourPort/index.html?Action=GetCapture&#038;Id=D1B831BF76B56038A6B0ADD3DDD663BA</p>
<p><strong>To Server : </strong><br />
&#8216;Action&#8217; = &#8216;GetCapture&#8217;<br />
&#8216;Id&#8217; => String => Needed<br />
<strong>From Server : </strong><br />
JPG => Image File</p>
<h1><strong>The AIR application:</strong></h1>
<p>It will manage (in an automatic way to catch) and interrogate the server, whether the final image is ready to be downloaded, and finally display the result.<br />
<a rel="attachment wp-att-219" href="http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotviewer_snap1/"><br />
<img class="aligncenter size-thumbnail wp-image-219" title="ScreenshotViewer_Snap1" src="http://blog.gafmediastudio.com/wp-content/uploads/ScreenshotViewer_Snap1-150x150.jpg" width="150" height="150" /><br />
</a></p>
<p>As always, it is the spirit of this blog, you will find various files to download below:<br />
<a href='http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_source/' rel='attachment wp-att-202'>Server Source</a><br />
<a href='http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotserver_exe/' rel='attachment wp-att-203'>Server Windows exe.</a><br />
<a href='http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotviewer_source/' rel='attachment wp-att-204'>Viewer source</a><br />
<a href='http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/screenshotviewer_air/' rel='attachment wp-att-205'>Viewer AIR</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/04/02/windows-serveur-for-graphic-web-page-capture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java : Draw a Pie Chart with Android</title>
		<link>http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/</link>
		<comments>http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 13:19:38 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Java-Android Class]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphisme]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://moulinier.l.free.fr/blog/?p=121</guid>
		<description><![CDATA[After developing a translation of LinkLite for Android, I decided to share with you my experience in this area by publishing the java class used to draw a graph (pie chart). This article is the second of a two-part series on this subject. The first dealing with the java class to draw a line chart. [...]]]></description>
			<content:encoded><![CDATA[<p>After developing a translation of <a href="http://linklite.gafmediastudio.com/" target="_blank">LinkLite</a> for Android, I decided to share with you my experience in this area by publishing the java class used to draw a graph (pie chart). This article is the second of a two-part series on this subject. The first dealing with the java class to draw a line chart.</p>
<p>Overview of results:<br />
<a href="http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/graphpie/" rel="attachment wp-att-130"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/GraphPie-163x300.png" alt="" title="GraphPie" width="163" height="300" class="aligncenter size-medium wp-image-130" /><br />
</a></p>
<p>First talk, the class defining the type of data to draw:</p>
<pre class="brush: java; ">

package com.gafmedia.Graph;
package com.gafmedia.Graph;
public class PieItem {
	public int Count;
	public String Label;
	public float Percent;
	public int Color;
}
</pre>
<p>In the case of our application, we have:<br />
<strong> Count </strong>: Represents the number to display in our pie, knowing that it will be divided by the total number to form the percentage.<br />
<strong> Label </strong>: The title of the portion of the pie.<br />
<strong> Percent </strong>: The percentage of the total. (Not used yet!).<br />
<strong> Color </strong>: The color of the portion of pie.</p>
<p>A graph is composed of several points, they will be placed in an array of type:</p>
<pre class="brush: java; ">

List&lt;PieItem&gt; PieData = new ArrayList&lt;PieItem&gt;(0);
</pre>
<p>To fill this table you can use, for example, a loop like this:</p>
<pre class="brush: java; ">

...
PieItem Item;
Random mNumGen = new Random();
int MaxPieItems = mNumGen.nextInt(20);
int ItemValue;
//-----------------------------------------------------------
// MaxCount nous servira plus tard et représente la somme
// de tous les ItemValue pour calculer le pourcentage.
//-----------------------------------------------------------
int MaxCount = 0;
for (int i = 0; i &lt; MaxPieItems ; i++) {
	ItemCount  = mNumGen.nextInt(256);
	Item       = new PieItem();
	Item.Count = ItemCount
	Item.Label = &quot;Valeur &quot; + mNumGen.nextInt(1000);
	Item.Color = 0xff000000 + 256*256*mNumGen.nextInt(256) + 256*mNumGen.nextInt(256) + mNumGen.nextInt(256);
	PieData.add(Item);
	MaxCount += ItemCount;
}
...
</pre>
<p>Once your table is full, you create your graph to handle it as follows:</p>
<pre class="brush: java; ">

...
//-----------------------------------------------
// OverlayId  =&gt;Image qui sera dessinée au dessus
// du camembert pour le rendre plus jolie !!!
//-----------------------------------------------
int OverlayId = R.drawable.cam_overlay_big;

View_PieChart PieChartView = new View_PieChart( this );
PieChartView.setLayoutParams(new LayoutParams(Size, Size));
PieChartView.setGeometry(Size, Size, 5, 5, 5, 5, OverlayId);
PieChartView.setSkinParams(BgColor);
PieChartView.setData(data, MaxCount);
PieChartView.invalidate();
...
</pre>
<p>Explanation of used methods:</p>
<pre class="brush: java; ">

public void setGeometry(int width, int height, int GapLeft, int GapRight, int GapTop, int GapBottom, int OverlayId) {
...
}
</pre>
<p>This method defines the geometric parameters of your View: Size (width, height) of your View, and then the border settings (GapLeft, GapRight, GapTop, GapBottom) and finally </p>
<p>(OverlayId) the ID of an image will be placed on top of pie, to improve the rendering. This method is called before anything else!.</p>
<pre class="brush: java; ">

public void setSkinParams(int bgColor){
...
}
</pre>
<p>The second method is called, defines the different display settings (bgColor) background color.</p>
<pre class="brush: java; ">

public void setData (List&lt;PieItem&gt; data, int MaxConnection) {
..
}
</pre>
<p>The last method defined values of the graph, and the number used to calculate the maximum percentage of each share. Calling this method unlocks the method OnDraw(), avoiding throwing </p>
<p>an exception if the data are not defined.</p>
<p>Finally, here is the class View_PieChart.java, to include in your application:</p>
<pre class="brush: java; ">

package com.gafmedia.Graph;

import com.gafmedia.Graph.PieItem;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.BitmapFactory.Options;
import android.util.AttributeSet;
import android.view.View;

public class View_PieChart extends View {
	private static final int WAIT = 0;
	private static final int IS_READY_TO_DRAW = 1;
	private static final int IS_DRAW = 2;
	private static final float START_INC = 30;
	private Paint mBgPaints   = new Paint();
	private Paint mLinePaints = new Paint();
	private int   mOverlayId;
	private int   mWidth;
	private int   mHeight;
	private int   mGapLeft;
	private int   mGapRight;
	private int   mGapTop;
	private int   mGapBottom;
	private int   mBgColor;
	private int   mState = WAIT;
	private float mStart;
	private float mSweep;
	private int   mMaxConnection;
	private List&lt;PieItem&gt; mDataArray;
	//--------------------------------------------------------------------------------------
	public View_PieChart (Context context){
		super(context);
	}
	//--------------------------------------------------------------------------------------
	public View_PieChart(Context context, AttributeSet attrs) {
        super(context, attrs);
	}
	//--------------------------------------------------------------------------------------
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		//------------------------------------------------------
		if (mState != IS_READY_TO_DRAW) return;
		canvas.drawColor(mBgColor);
		//------------------------------------------------------
		mBgPaints.setAntiAlias(true);
		mBgPaints.setStyle(Paint.Style.FILL);
		mBgPaints.setColor(0x88FF0000);
		mBgPaints.setStrokeWidth(0.5f);
		//------------------------------------------------------
		mLinePaints.setAntiAlias(true);
		mLinePaints.setStyle(Paint.Style.STROKE);
		mLinePaints.setColor(0xff000000);
		mLinePaints.setStrokeWidth(0.5f);
		//------------------------------------------------------
		RectF mOvals = new RectF( mGapLeft, mGapTop, mWidth - mGapRight, mHeight - mGapBottom);
		//------------------------------------------------------
		mStart = START_INC;
		PieItem Item;
		for (int i = 0; i &lt; mDataArray.size(); i++) {
			Item = (PieItem) mDataArray.get(i);
			mBgPaints.setColor(Item.Color);
			mSweep = (float) 360 * ( (float)Item.Count / (float)mMaxConnection );
			canvas.drawArc(mOvals, mStart, mSweep, true, mBgPaints);
			canvas.drawArc(mOvals, mStart, mSweep, true, mLinePaints);
			mStart += mSweep;
		}
		//------------------------------------------------------
		Options options = new BitmapFactory.Options();
		options.inScaled = false;
		Bitmap OverlayBitmap = BitmapFactory.decodeResource(getResources(), mOverlayId, options);
		canvas.drawBitmap(OverlayBitmap, 0.0f, 0.0f, null);
		//------------------------------------------------------
		mState = IS_DRAW;
	}
	//--------------------------------------------------------------------------------------
	public void setGeometry(int width, int height, int GapLeft, int GapRight, int GapTop, int GapBottom, int OverlayId) {
		mWidth     = width;
		mHeight    = height;
		mGapLeft   = GapLeft;
		mGapRight  = GapRight;
		mGapTop    = GapTop;
		mGapBottom = GapBottom;
		mOverlayId = OverlayId;
	}
	//--------------------------------------------------------------------------------------
	public void setSkinParams(int bgColor) {
		mBgColor   = bgColor;
	}
	//--------------------------------------------------------------------------------------
	public void setData(List&lt;PieItem&gt; data, int MaxConnection) {
		mDataArray = data;
		mMaxConnection = MaxConnection;
		mState = IS_READY_TO_DRAW;
	}
	//--------------------------------------------------------------------------------------
	public void setState(int State) {
		mState = State;
	}
	//--------------------------------------------------------------------------------------
	public int getColorValue( int Index ) {
		if (mDataArray == null) return 0;
		if (Index &lt; 0){
			return ((PieItem)mDataArray.get(0)).Color;
		} else if (Index &gt;= mDataArray.size()){
			return ((PieItem)mDataArray.get(mDataArray.size()-1)).Color;
		} else {
			return ((PieItem)mDataArray.get(mDataArray.size()-1)).Color;
		}
	}
}
</pre>
<p>As always, you can download all files <a href='http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/view_piechart/' rel='attachment wp-att-134'> HERE </a>.</p>
<p><strong>(14-12-2010) UPDATE : </strong><br />
I add an ANDROID sample with this class, you can download it <a href='http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/piechartsample/' rel='attachment wp-att-451'>HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/04/01/draw-a-pie-chart-with-android/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Java : Draw a Line Chart with Android</title>
		<link>http://blog.gafmediastudio.com/2010/04/01/draw-a-line-chart-with-android/</link>
		<comments>http://blog.gafmediastudio.com/2010/04/01/draw-a-line-chart-with-android/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 09:04:22 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[Java-Android Class]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Graphisme]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://moulinier.l.free.fr/blog/?p=87</guid>
		<description><![CDATA[After developing a translation of LinkLITE for Android, I decided to share with you my experience in this area by publishing the java class used to draw a graph (line). This article is the first of a series of two on this subject. The second deal, the java class to draw a pie graph, following [...]]]></description>
			<content:encoded><![CDATA[<p>After developing a translation of <a href="http://linklite.gafmediastudio.com/" target="_blank">LinkLITE </a> for Android, I decided to share with you my experience in this area by publishing the java class used to draw a graph (line). This article is the first of a series of two on this subject. The second deal, the java class to draw a pie graph, following the same principle.</p>
<p>Overview of results:<br />
<a href="http://blog.gafmediastudio.com/2010/04/01/draw-a-line-chart-with-android/graphline/" rel="attachment wp-att-141"><br />
<img src="http://blog.gafmediastudio.com/wp-content/uploads/GraphLine-163x300.png" title="GraphLine" width="163" height="300" class="aligncenter size-medium wp-image-141"/><br />
</a></p>
<p>First talk, the class defining the type of data to draw:</p>
<pre class="brush: java; ">

package com.gafmedia.Graph;
public class LineChartItem {
	public String Date;
	public int Connection;
}
</pre>
<p>In the case of our application, we have: X: Date (String), and Y: Connect (int).</p>
<p>A graph is composed of several points, they will be placed in an array of type :</p>
<pre class="brush: java; ">

List&lt;LineChartItem&gt; LineChartArray = new ArrayList&lt;LineChartItem&gt;(0);
</pre>
<p>To fill this table you can use, for example, a loop like this:</p>
<pre class="brush: java; ">

...
for (int i = StartIndex; i &lt; EndIndex; i++) {
	ItemNode   = (Element) AllNodes.item(i);
	Day        = ItemNode.getAttribute(&quot;day&quot;);
	Month      = ItemNode.getAttribute(&quot;month&quot;);
	Year       = ItemNode.getAttribute(&quot;year&quot;);
	try {
		Connection = NumberFormater.parse(ItemNode.getAttribute(&quot;value&quot;)).intValue();
	} catch (java.text.ParseException e) {
		e.printStackTrace();
	}
	ChartItem = new LineChartItem();
	ChartItem.Date = Day + &quot;-&quot; + Month + &quot;-&quot; + Year;
	ChartItem.Connection = Connection;
	LineChartArray.add(ChartItem);
}
...
</pre>
<p>Once your table is full, you create your graph to handle it as follows:</p>
<pre class="brush: java; ">

...
View_LineChart mTmpChartView = new View_LineChart(this);
mTmpChartView.setGeometry(mHolderWidth, mHolderHeight, CHART_LEFT_GAP, CHART_RIGHT_GAP, CHART_GAP_TOP, CHART_GAP_BOTTOM);
if(mWhiteGraph == true){
	mTmpChartView.setSkinParams(mWhiteBgColor, mWhiteGridColor, mWhiteLineColor, mWhiteTxtColor, mFillGraph, mAverageLine, mZoomChart);
} else {
	mTmpChartView.setSkinParams(mBlackBgColor, mBlackGridColor, mBlackLineColor, mBlackTxtColor, mFillGraph, mAverageLine, mZoomChart);
}
mTmpChartView.setData(LineChartArray, mUrl);
mTmpChartView.invalidate();
...
</pre>
<p>Explanation of used methods:</p>
<pre class="brush: java; ">

public void setGeometry(int width, int height, int GapLeft, int GapRight, int GapTop, int GapBottom) {
...
}
</pre>
<p>This method defines the geometric parameters of your View: size (width, height), then the border settings (GapLeft, GapRight, GapTop, GapBottom). This method is called before anything </p>
<p>else!.</p>
<pre class="brush: java; ">

public void setSkinParams(int bgColor, int gridColor, int lineColor, int textColor, boolean FillGraph, boolean AverageLine, boolean ZoomChart) {
...
}
</pre>
<p>The second method is called, defines the various display settings, first the different colors to use (bgColor (background), GridColor (Grid), LineColor (Line), textColor (Text)), then </p>
<p>the different things to show or not: (FillGraph) indicates whether the graph is full, or just display as a line (AverageLine) indicates whether the line of average values of Y is </p>
<p>shown or not, and finally (ZoomChart) indicates whether the graph from scratch Also on display or if it is between the minimum and maximum value of Y.</p>
<pre class="brush: java; ">

public void setData( List&lt;LineChartItem&gt; ChartArray, String  Url) {
..
}
</pre>
<p>The last method defined values of the graph. Calling this method unlocks the method OnDraw (), avoiding throwing an exception if the data are not defined.</p>
<p>Finally, here is the class View_LineChart.java, to include in your application:</p>
<pre class="brush: java; ">

package com.gafmedia.Graph;

import com.gafmedia.Graph.LineChartItem;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;

public class View_LineChart extends View {
	public static final int LABEL_X_SHOW = 7;
	public static final int LABEL_Y_SHOW = 6;

	private Canvas mCanvas          = null;
	private Paint  mBGPaint         = new Paint();
	private Paint  mLinePaint       = new Paint();
	private Paint  mGridPaintFull   = new Paint();
	private Paint  mGridPaintDot    = new Paint();
	private Paint  mTitlePaint      = new Paint();
	private Paint  mAveragePaint    = new Paint();
	private Paint  mAverageTxtPaint = new Paint();

	private boolean  isReadyToDraw = false;

	private int      mWidth;
	private int      mHeight;
	private boolean  mFillGraph;
	private boolean  mAverageLine;
	private boolean  mZoomChart;

	private int      mGapLeft;
	private int      mGapRight;
	private int      mGapTop;
	private int      mGapBottom;

	private int      mBgColor;
	private int      mGridColor;
	private int      mLineColor;
	private int      mTextColor;

	private String   mUrl;
	List&lt;LineChartItem&gt; mLineChartArray = new ArrayList&lt;LineChartItem&gt;();
	//--------------------------------------------------------------------------------------
	public View_LineChart (Context context){
		super(context);
	}
	//--------------------------------------------------------------------------------------
	public View_LineChart(Context context, AttributeSet attrs) {
        super(context, attrs);
	}
	//--------------------------------------------------------------------------------------
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		if (isReadyToDraw == false) return;
		mCanvas = canvas;
		//--------------------------------------------------------------------------
		mBGPaint.setStyle(Paint.Style.FILL);
		mBGPaint.setColor(mBgColor);
		mCanvas.drawPaint(mBGPaint);
		//--------------------------------------------------------------------------
		mLinePaint.setColor(mLineColor);
		if (mFillGraph == true){
			mLinePaint.setStyle(Paint.Style.FILL_AND_STROKE);
		} else {
			mLinePaint.setStyle(Paint.Style.FILL);
		}
		mLinePaint.setAntiAlias(true);
		mLinePaint.setStrokeWidth(1.5f);
		//--------------------------------------------------------------------------
		mGridPaintDot.setColor(mGridColor);
		mGridPaintDot.setAntiAlias(false);
		mGridPaintDot.setStyle(Paint.Style.STROKE);
		mGridPaintDot.setStrokeWidth(0.5f);
		mGridPaintDot.setPathEffect( new DashPathEffect(new float[] {5,5 }, 1) );
		//--------------------------------------------------------------------------
		mGridPaintFull.setColor(mGridColor);
		mGridPaintFull.setAntiAlias(false);
		mGridPaintFull.setStyle(Paint.Style.STROKE);
		mGridPaintFull.setStrokeWidth(1.0f);
		//--------------------------------------------------------------------------
		mTitlePaint.setStyle(Paint.Style.FILL);
		mTitlePaint.setTextAlign(Paint.Align.LEFT);
		mTitlePaint.setColor(mTextColor);
		mTitlePaint.setTextSize(10);
		//--------------------------------------------------------------------------
		Rect TextRect = new Rect();
		//----------------------------------------------------------------------------------
		// Get Y Max Values
		//----------------------------------------------------------------------------------
		String StrLablel;
		LineChartItem ChartItem;
		float y;
		int   Index;
		int   value;
		float OldX;
		float OldY;
		float NewX;
		float NewY;
		int   maxY         = 0;
		int   minY         = 0;
		int   ValuesCount  = mLineChartArray.size();
		float graphAverage = 0;
		//----------------------------------------------------------------------------------
		// GET Y MIN &amp; MAX
		//----------------------------------------------------------------------------------
		for (int i = 0; i&lt;ValuesCount; i++){
			ChartItem = mLineChartArray.get(i);
			if (maxY &lt; ChartItem.Connection) maxY = ChartItem.Connection;
			graphAverage += ChartItem.Connection;
		}
		if (mZoomChart == true){
			minY = maxY;
			for (int i = 0; i&lt;ValuesCount; i++){
				ChartItem = mLineChartArray.get(i);
				if (minY &gt; ChartItem.Connection) minY = ChartItem.Connection;
			}
		} else {
			minY = 0;
		}
		graphAverage = graphAverage / (float)ValuesCount;
		//----------------------------------------------------------------------------------
		// DRAW Y AXIS
		//----------------------------------------------------------------------------------
		float step  = (float) (maxY - minY) / (float) (LABEL_Y_SHOW);
		float stepY = (float) (mHeight - mGapTop - mGapBottom) / (float) (maxY - minY);
		for (int i = 0; i &lt;= LABEL_Y_SHOW ; i++) {
			y = (float) ((i * step) * stepY);
			OldX = (float) (mGapLeft - 2);
			OldY = (float) (mHeight - mGapBottom - y);
			NewX = (float) (mWidth - mGapRight);
			NewY = (float) (mHeight - mGapBottom - y);
			if (i == 0) mCanvas.drawLine(OldX, OldY, NewX, NewY, mGridPaintFull);
			else  mCanvas.drawLine(OldX, OldY, NewX, NewY, mGridPaintDot);
			//----------------------------------------------------------------------
			value     = (int) minY + (int)(i * step);
			StrLablel = &quot;&quot; + value;
			mCanvas.drawText(StrLablel, 2, NewY, mTitlePaint);
		}
		//----------------------------------------------------------------------------------
		// DRAW X AXIS
		//----------------------------------------------------------------------------------
		float stepX     = (float) (mWidth - mGapLeft - mGapRight) / (float) (LABEL_X_SHOW - 1);
		float IndexStep = (float) ValuesCount / (float) LABEL_X_SHOW;
		NewY = (float)(mHeight - mGapBottom);
		String[] DateItem = new String[3];
		for (int j = 0; j&lt;LABEL_X_SHOW; j++){
			Index = (int) ((float)(j)* (float)IndexStep);
			if (Index &gt;= ValuesCount) Index = ValuesCount - 1;
			if (j == LABEL_X_SHOW -1) Index = ValuesCount - 1;
			NewX = (float)( (float) mGapLeft +  (float)(j*stepX) );
			//--------------------------------------------------------------------------
			if (j == 0) mCanvas.drawLine(NewX, mGapTop, NewX, NewY+3, mGridPaintFull);
			else  mCanvas.drawLine(NewX, mGapTop, NewX, NewY+3, mGridPaintDot);
			//--------------------------------------------------------------------------
			ChartItem = mLineChartArray.get(Index);
			DateItem  = ChartItem.Date.split(&quot;-&quot;);
			StrLablel = DateItem[0] + &quot;-&quot; + DateItem[1];
			mTitlePaint.getTextBounds(StrLablel, 0, StrLablel.length(), TextRect);
			NewX = NewX - TextRect.right/2;
			mCanvas.drawText(StrLablel, NewX, (mHeight - mGapBottom) + 13, mTitlePaint);
		}
		//--------------------------------------------------------------------------
		// Draw Graph Lines
		//--------------------------------------------------------------------------
		float pointStepX  = (float) (mWidth - mGapLeft - mGapRight) / (float) (ValuesCount-1);
		float pointStepY  = (float) (mHeight - mGapTop - mGapBottom) / (float) (maxY - minY );
		float drawOffsetX = (float) mGapLeft;
		float drawOffsetY = (float)( mHeight - mGapBottom);
		//--------------------------------------------------------------------------
		ChartItem = mLineChartArray.get(0);
		OldX      = drawOffsetX;
		OldY      = drawOffsetY - pointStepY * (float) (ChartItem.Connection - minY);
		Path mPath = new Path();
		for (int k = 0; k&lt;ValuesCount; k++){
			ChartItem = mLineChartArray.get(k);
			NewX      = drawOffsetX + ( pointStepX * (float) k );
			NewY      = drawOffsetY - ( pointStepY * (float) ( ChartItem.Connection - minY) );
			if (mFillGraph == false){
				mCanvas.drawLine(OldX, OldY, NewX, NewY, mLinePaint);
			} else {
				mPath.rewind();
				mPath.moveTo(OldX, OldY);
				mPath.lineTo(NewX, NewY);
				mPath.lineTo(NewX, drawOffsetY);
				mPath.lineTo(OldX, drawOffsetY);
				mPath.close();
				mCanvas.drawPath(mPath, mLinePaint);
			}
			OldX = NewX;
			OldY = NewY;
		}
		//--------------------------------------------------------------------------
		// Average Line
		//--------------------------------------------------------------------------
		if (mAverageLine == true){
			mAveragePaint.setColor(0xffff0000);
			mAveragePaint.setStyle(Paint.Style.FILL);
			mAveragePaint.setAntiAlias(true);
			mAveragePaint.setStrokeWidth(1.5f);
			mAveragePaint.setPathEffect( new DashPathEffect(new float[] {5, 5}, 1) );
			//--------------------------------------------------------------------------
			mAverageTxtPaint.setStyle(Paint.Style.FILL);
			mAverageTxtPaint.setTextAlign(Paint.Align.LEFT);
			mAverageTxtPaint.setColor(0xffff0000);
			mAverageTxtPaint.setTextSize(10);
			//--------------------------------------------------------------------------
			DecimalFormat FloatFormatter = new DecimalFormat(&quot;0.##&quot;);
			String StrAverage = &quot;&quot; + FloatFormatter.format (graphAverage);
			mAverageTxtPaint.getTextBounds(StrAverage, 0, StrAverage.length(), TextRect);
			NewX = (float)( mWidth - mGapRight - TextRect.right) - 3.0f;
			NewY = (float)( mGapTop - TextRect.top) + 3.0f;
			mCanvas.drawText(StrAverage, NewX, NewY, mAverageTxtPaint);
			NewY = drawOffsetY - ( pointStepY * (float) ( graphAverage - minY) );
			mCanvas.drawLine(mGapLeft, NewY, mWidth - mGapRight, NewY, mAveragePaint);
		}
		//--------------------------------------------------------------------------
		// Title
		//--------------------------------------------------------------------------
		ChartItem    = mLineChartArray.get(0);
		String Title =  mLineChartArray.get(0).Date  + &quot; ... &quot; + mLineChartArray.get(ValuesCount-1).Date;
		mTitlePaint.getTextBounds(Title, 0, Title.length(), TextRect);
		mCanvas.drawText(Title, (mWidth - TextRect.right)/2, 10, mTitlePaint);
		//--------------------------------------------------------------------------
		Title = mUrl;
		mTitlePaint.getTextBounds(Title, 0, Title.length(), TextRect);
		mCanvas.drawText(Title, (mWidth - TextRect.right)/2, 20, mTitlePaint);
	}
	//--------------------------------------------------------------------------------------
	public void setGeometry(int width, int height, int GapLeft, int GapRight, int GapTop, int GapBottom) {
		mWidth     = width;
		mHeight    = height;
		mGapLeft   = GapLeft;
		mGapRight  = GapRight;
		mGapTop    = GapTop;
		mGapBottom = GapBottom;
	}
	//--------------------------------------------------------------------------------------
	public void setSkinParams(int bgColor, int gridColor, int lineColor, int textColor, boolean FillGraph, boolean AverageLine, boolean ZoomChart) {
		mBgColor     = bgColor;
		mGridColor   = gridColor;
		mLineColor   = lineColor;
		mTextColor   = textColor;
		mFillGraph   = FillGraph;
		mAverageLine = AverageLine;
		mZoomChart   = ZoomChart;
	}
	//--------------------------------------------------------------------------------------
	public void setData( List&lt;LineChartItem&gt;  ChartArray, String  Url) {
		mLineChartArray = ChartArray;
		mUrl = Url;
		isReadyToDraw = true;
	}
}
</pre>
<p>As always, you can download all files <a href='http://blog.gafmediastudio.com/2010/04/01/draw-a-line-chart-with-android/view_linechart/' rel='attachment wp-att-102'>HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/04/01/draw-a-line-chart-with-android/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>AS3 : Windows Bitmap Codec</title>
		<link>http://blog.gafmediastudio.com/2010/03/31/as3-windows-bitmap-codec/</link>
		<comments>http://blog.gafmediastudio.com/2010/03/31/as3-windows-bitmap-codec/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 12:07:54 +0000</pubDate>
		<dc:creator>Laurent</dc:creator>
				<category><![CDATA[AS3 Class]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Class]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[FLEX]]></category>

		<guid isPermaLink="false">http://moulinier.l.free.fr/blog/?p=37</guid>
		<description><![CDATA[There are some time ago, we have developed an AS3-AIR class, for reading and writing Windows bitmap file. MswBMPCodec.as Class file content : package msw.asBitmap { import flash.display.BitmapData; import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; import flash.utils.ByteArray; import flash.utils.Endian; public class MswBMPCodec { private const MASK : int = 0xFF; public var FileData : Object; //**************************************************** [...]]]></description>
			<content:encoded><![CDATA[<p>There are some time ago, we have developed an AS3-AIR class, for reading and writing Windows bitmap file.</p>
<p>MswBMPCodec.as Class file content :</p>
<pre class="brush: as3; ">

package msw.asBitmap
{
	import flash.display.BitmapData;
	import flash.filesystem.File;
	import flash.filesystem.FileMode;
	import flash.filesystem.FileStream;
	import flash.utils.ByteArray;
	import flash.utils.Endian;

	public class MswBMPCodec
	{
		private const MASK     : int = 0xFF;
		public  var   FileData : Object;

		//****************************************************
		// Class Constructor !!!
		//****************************************************
		public function MswBMPCodec()
		{
			FileData = new Object();
			super();
		}
		//****************************************************
		// Function Read BMP file with path
		//****************************************************
		public function ReadBMPWithFilename(filename : String ) : BitmapData {
			var BmpFile : File = new File(filename);
			return ReadBMP( BmpFile );
		}
		//****************************************************
		// Function Read BMP file with File
		//****************************************************
		public function ReadBMP(BmpFile : File) : BitmapData {
			var BufferedImage : BitmapData;
			try{
			 	var I   : int;
				var J   : int;
				var K   : int
			 	var Blue  : int = 0;
				var Red   : int = 0;
				var Green : int = 0;
				var Alpha : int = 0;
			 	var Bytes     : ByteArray  = new ByteArray();
			 	Bytes.endian = Endian.LITTLE_ENDIAN;

			 	var BmpStream : FileStream = new FileStream();
				BmpStream.open(BmpFile, FileMode.READ);
				BmpStream.position = 0;
				BmpStream.readBytes(Bytes, 0, BmpFile.size );
				BmpStream.close();
				//------------------------------------------------------
			 	// La signature (sur 2 octets), indiquant qu&#039;il s&#039;agit
				// d&#039;un fichier BMP à l&#039;aide des deux caractères.
				// BM,indique qu&#039;il s&#039;agit d&#039;un Bitmap Windows.
				// BA indique qu&#039;il s&#039;agit d&#039;un Bitmap OS/2.
				// CI indique qu&#039;il s&#039;agit d&#039;une icone couleur OS/2.
				// CP indique qu&#039;il s&#039;agit d&#039;un pointeur de couleur OS/2.
				// IC indique qu&#039;il s&#039;agit d&#039;une icone OS/2.
				// PT indique qu&#039;il s&#039;agit d&#039;un pointeur OS/2.
				//------------------------------------------------------
			 	FileData.signature  = Bytes.readShort();
			 	if (FileData.signature != 0x4D42){
					return null;
				}
		        	//------------------------------------------------------
			 	// La taille totale du fichier en octets (4 octets)
			 	//------------------------------------------------------
			 	FileData.size       = Bytes.readInt();
			 	//------------------------------------------------------
			 	// Un champ réservé (4 octets)
			 	//------------------------------------------------------
			 	FileData.reserved   = Bytes.readInt();
			 	//------------------------------------------------------
			 	// L&#039;offset de l&#039;image (4 octets), c&#039;est-à-dire
				// l&#039;adresse relative du début des informations concernant
				// l&#039;image par rapport au début du fichier
				//------------------------------------------------------
			 	FileData.offset = Bytes.readInt();
			 	//------------------------------------------------------
			 	// La taille de l&#039;entête de l&#039;image en octets (4 octets).
			 	// Les valeurs hexadécimales suivantes sont possibles
				// suivant le type de format BMP :
          			// 28 pour Windows 3.1x, 95, NT, ...
          			// 0C pour OS/2 1.x
          			// F0 pour OS/2 2.x
          			//------------------------------------------------------
			 	FileData.headerSize = Bytes.readInt();
			 	if (FileData.headerSize != 0x28){
		           		return null;
		        	}
		        	//------------------------------------------------------
				// La largeur de l&#039;image (4 octets), c&#039;est-à-dire le
				// nombre de pixels horizontalement
				//------------------------------------------------------
			 	FileData.width      = Bytes.readInt();
			 	//------------------------------------------------------
			 	//La hauteur de l&#039;image (4 octets), c&#039;est-à-dire le
				// nombre de pixels verticalement
			 	//------------------------------------------------------
			 	FileData.height     = Bytes.readInt();
				//------------------------------------------------------
				// Le nombre de plans (2 octets). Cette valeur vaut
				// toujours 1
				//------------------------------------------------------
				FileData.mapCount   = Bytes.readShort();
				//------------------------------------------------------
				// La profondeur de codage de la couleur (2 octets),
				// c&#039;est-à-dire le nombre de bits utilisés pour coder la
				// couleur. Cette valeur peut-être égale à 1, 4, 8, 16,
				// 24 ou 32
				//------------------------------------------------------
				FileData.byteDepth = Bytes.readShort();
		        	if (FileData.byteDepth &lt; 24){
		        		return null;
		        	}
		        	//------------------------------------------------------
				// La méthode de compression (4 octets). Cette valeur
				// vaut 0 lorsque l&#039;image n&#039;est pas compressée,
				// ou bien 1, 2, 3 ou 4 suivant le type de compression
				// utilisé  :
				// 0 pas de compression
          			// 1 pour un codage RLE de 8 bits par pixel
          			// 2 pour un codage RLE de 4 bits par pixel
          			// 3 pour un codage bitfields, signifiant que la couleur
				// est codé par un triple masque représenté par la palette
          			// 3 pour un codage Huffman, signifiant 1-bit-per-pixel
				// modified Huffman compression
          			// 4 pour un codage RLE de 24 bits par pixel
          			//------------------------------------------------------
				FileData.compression = Bytes.readInt();
				//------------------------------------------------------
				// La taille totale de l&#039;image en octets (4 octets).
				//------------------------------------------------------
				FileData.imageSize = Bytes.readInt();
				//------------------------------------------------------
				// La résolution horizontale (4 octets), c&#039;est-à-dire
				// le nombre de pixels par mètre horizontalement
				//------------------------------------------------------
				FileData.horizontalResolution = Bytes.readInt();
				//------------------------------------------------------
    				// La résolution verticale (4 octets), c&#039;est-à-dire
				// le nombre de pixels par mètre verticalement
    				//------------------------------------------------------
    				FileData.verticalResolution  = Bytes.readInt();
    				//------------------------------------------------------
    				// Le nombre de couleurs de la palette (4 octets)
    				//------------------------------------------------------
    				FileData.colorPaletteCount = Bytes.readInt();
    				//------------------------------------------------------
    				// Le nombre de couleurs importantes de la palette
				// (4 octets). Ce champ peut être égal à 0 lorsque
				// chaque couleur a son importance.
    				//------------------------------------------------------
    				FileData.significantColorsCount = Bytes.readInt();
    				if (FileData.colorPaletteCount &gt; 0){
    					var ColorArray : Array = new Array();
    					for(var loop : int = 1;  loop = 4*FileData.colorPaletteCount; loop ++){
    						Blue  = Bytes.readUnsignedByte();
						Green = Bytes.readUnsignedByte();
						Red   = Bytes.readUnsignedByte();
						Alpha = Bytes.readUnsignedByte();
					 	ColorArray.push(256*256*Red + 256*Green+Blue);
    					}
    					FileData.paletteColor = ColorArray;
    				}
    				//------------------------------------------------------
    				// Lecture des Données !!!
    				//------------------------------------------------------
    				Bytes.position = FileData.offset;
    				switch(FileData.byteDepth) {
					case 24:
						BufferedImage = new BitmapData(FileData.width, FileData.height, false, 0x000000);
					    	break;
					case 32:
			 			BufferedImage = new BitmapData(FileData.width, FileData.height, true, 0x00000000);
			 			break;
    				}
				var JunkCount : int = (FileData.width * 3) % 4;
			 	switch(FileData.byteDepth) {
					case 24:
						for(J = FileData.height - 1; J &gt;= 0; J--){
					 		for(I = 0; I &lt; FileData.width ; I++){
					 			Blue  = Bytes.readUnsignedByte();
								Green = Bytes.readUnsignedByte();
								Red   = Bytes.readUnsignedByte();
					 			BufferedImage.setPixel( I, J, 256*256*Red + 256*Green + Blue);
					 		}
					 		for(K = 0; K &lt; JunkCount; K++){
					 			Bytes.readUnsignedByte();
					 		}
						}
					    	break;

					case 32:
						for(J = FileData.height - 1; J &gt;= 0; J--){
					 		for(I = 0; I &lt; FileData.width; I++){
					 			Blue  = Bytes.readUnsignedByte();
								Green = Bytes.readUnsignedByte();
								Red   = Bytes.readUnsignedByte();
								Alpha = Bytes.readUnsignedByte();
					 			BufferedImage.setPixel32( I, J, 256*256*256*Alpha + 256*256*Red + 256*Green + Blue);
					 		}
						}
						break;
				}
			} catch(e:Error){
			} finally {}

			return BufferedImage;
		}
		//****************************************************
		// Function Write BMP file with path
		//****************************************************
		public function writeBMPWithFilename(BufferedImage : BitmapData, filename : String ) : Boolean {
			var BmpFile : File = new File(filename);
			return writeBMP(BufferedImage, BmpFile);
		}
		//****************************************************
		// Function Write BMP file with File
		//****************************************************
		public function writeBMP(BufferedImage : BitmapData, BmpFile : File) : Boolean {
			try{
		 		var Result : Boolean   = true;
		 		var Width  : int       = BufferedImage.width;
				var Height : int       = BufferedImage.height;
				var Bytes  : ByteArray = new ByteArray();
			 	Bytes.endian = Endian.LITTLE_ENDIAN;
			 	//------------------------------------------------------
			 	// La signature (sur 2 octets), indiquant qu&#039;il s&#039;agit
				// d&#039;un fichier BMP à l&#039;aide des deux caractères.
				// BM,indique qu&#039;il s&#039;agit d&#039;un Bitmap Windows.
				//------------------------------------------------------
		 		Bytes.writeShort(0x424D);
		 		//------------------------------------------------------
		 		// La taille totale du fichier en octets (4 octets)
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(Width*Height*4 + 0x36);
		 		//------------------------------------------------------
		 		// Un champ réservé (sur 4 octets)
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x00);
		 		//------------------------------------------------------
		 		// L&#039;offset de l&#039;image (4 octets), c&#039;est-à-dire
				// l&#039;adresse relative du début des informations concernant
				// l&#039;image par rapport au début du fichier
				//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x36);
		 		//------------------------------------------------------
		 		// La taille de l&#039;entête de l&#039;image en octets (4 octets).
			 	// Les valeurs hexadécimales suivantes sont possibles
				// suivant le type de format BMP :
				// 28 pour Windows 3.1x, 95, NT, ...
				// 0C pour OS/2 1.x
				// F0 pour OS/2 2.x
				//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x28);
		 		//------------------------------------------------------
		 		// La largeur de l&#039;image (4 octets), c&#039;est-à-dire
				// le nombre de pixels horizontalement
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(Width);
		 		//------------------------------------------------------
		 		//La hauteur de l&#039;image (4 octets), c&#039;est-à-dire
				// le nombre de pixels verticalement
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(Height);
		 		//------------------------------------------------------
		 		// Le nombre de plans (2 octets). Cette valeur vaut
				// toujours 1
		 		//------------------------------------------------------
		 		Bytes.writeShort(0x01);
				//------------------------------------------------------
		 		// La profondeur de codage de la couleur(2 octets),
				// c&#039;est-à-dire le nombre de bits utilisés pour coder
				// la couleur. Cette valeur peut-être égale à 1, 4, 8,
				// 16, 24 ou 32
				//------------------------------------------------------
		 		Bytes.writeShort(0x20);
		 		//------------------------------------------------------
		 		// La méthode de compression (4 octets). Cette valeur
				// vaut 0 lorsque l&#039;image n&#039;est pas compressée,
				// ou bien 1, 2 ou 3 suivant le type de compression
				// utilisé  :
				// 0 pas de compression
				// 1 pour un codage RLE de 8 bits par pixel
				// 2 pour un codage RLE de 4 bits par pixel
				// 3 pour un codage bitfields, signifiant que la couleur
				// est codé par un triple masque représenté par la palette
				// 3 pour un codage Huffman, signifiant 1-bit-per-pixel
				// modified Huffman compression
				// 4 pour un codage RLE de 24 bits par pixel
				//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x00);
		 		//------------------------------------------------------
		 		// La taille totale de l&#039;image en octets (4 octets).
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(Width*Height*4);
		 		//------------------------------------------------------
		 		// La résolution horizontale (4 octets), c&#039;est-à-dire
				// le nombre de pixels par mètre horizontalement
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x0EC4);
		 		//------------------------------------------------------
		 		// La résolution verticale (4 octets), c&#039;est-à-dire
				// le nombre de pixels par mètre verticalement
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x0EC4);
		 		//------------------------------------------------------
		 		// Le nombre de couleurs de la palette (4 octets)
		 		//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x00);
		 		//------------------------------------------------------
		 		// Le nombre de couleurs importantes de la palette
				// (4 octets). Ce champ peut être égal à 0 lorsque
				// chaque couleur a son importance.
				//------------------------------------------------------
		 		Bytes.writeUnsignedInt(0x00);
		 		//------------------------------------------------------
		 		//Ecriture du corps du fichier BMP
		 		//------------------------------------------------------
		 		for (var Y : int = Height - 1; Y &gt;= 0; Y--) {
		 			for (var X : int = 0; X &lt; Width; X++) {
		 				Bytes.writeUnsignedInt( BufferedImage.getPixel32(X,Y) );
		 			}
		 		}
		 		//------------------------------------------------------
		 		// Enregistrement du fichier
		 		//------------------------------------------------------
		 		var BmpStream : FileStream = new FileStream();
				BmpStream.open(BmpFile, FileMode.WRITE);
				BmpStream.position = 0;
				BmpStream.writeBytes(Bytes);
			 	BmpStream.close();
				return true;
		 	} catch(e:Error){
		 		return false;
		 	}
		 	return true;
		}
	}
}
</pre>
<p><strong>Use : <em>(Functions written on the fly and not tested!)</em></strong></p>
<pre class="brush: as3; ">

import msw.asBitmap.MswBMPCodec;
....
public function ConvertBmpToJpg(BmpFile: File, JpgFile : File) : void {
	var BmpEncoder : MswBMPCodec = new MswBMPCodec();
	var BmpBitmapData : BitmapData = BmpEncoder.ReadBMP(BmpFile);
	var jpg : JPEGEncoder = new JPEGEncoder(100);
	var ResByteArray  : ByteArray   = jpg.encode(BmpBitmapData);
	var fileStream : FileStream = new FileStream();
	fileStream.open(JpgFile, FileMode.WRITE);
	fileStream.writeBytes(ResByteArray);
	fileStream.close();
}

public function ConvertJpgToBmp(BmpFile: File, JpgFile : File) : void {
	private function ImageLoadHandler(event : Event) : void {
		event .target.removeEventListener(Event.COMPLETE, ImageLoadHandler)
		var BmpEncoder : MswBMPCodec = new MswBMPCodec();
		BmpEncoder.writeBMP(event .target.content.bitmapData, BmpFile);
	}
	var loader : Loader = new Loader();
	loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoadHandler, false, 0, true)
	loader.load( new URLRequest(JpgFile.url) );
}
</pre>
<p>You can download files<a rel="attachment wp-att-145" href="http://blog.gafmediastudio.com/2010/03/31/as3-windows-bitmap-codec/msw_as3_bitmap_class/">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.gafmediastudio.com/2010/03/31/as3-windows-bitmap-codec/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

