by loucsam » March 2nd, 2010, 5:45 am
by loucsam » March 2nd, 2010, 6:01 am
by playstation3Dood » March 2nd, 2010, 7:38 am
by Benjaminsen » March 2nd, 2010, 9:11 am
by playstation3Dood » March 2nd, 2010, 9:14 am
by loucsam » March 2nd, 2010, 9:34 am
var imageLoader:Loader = new Loader();
var image:URLRequest = new URLRequest("http://img.ngfiles.com/emoticons/emote-1.gif");
imageLoader.load(image);
addChild (imageLoader);
imageLoader.x = 200;
imageLoader.y = 300;
by default0 » March 2nd, 2010, 4:56 pm
by mindfoolgames » March 3rd, 2010, 6:45 am
imageLoader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
imageLoader.load(new URLRequest("http://www.mindfoolgames.com/images/layout_jovyInCircleW.jpg"));
connection.addMessageHandler("imageLoadResp", function(m:Message, x:int, y:int, b:ByteArray) {
trace("imageLoadHandler--> " + x + "," + y + " " + b.length);
var bm3:BitmapData = new BitmapData(x,y);
bm3.setPixels(bm3.rect, b);
addChild(new Bitmap(bm3));
})
private function loadComplete(event:Event):void {
var loadedImage:Bitmap = Bitmap(imageLoader.content);
var bitmap:BitmapData = loadedImage.bitmapData;
var bytes:ByteArray = bitmap.getPixels(bitmap.rect);
connection.send("imageLoad", loadedImage.width, loadedImage.height, bytes);
}
case "imageLoad":
Console.WriteLine("imageLoad--> " + message.GetInt(0) + "," + message.GetInt(1));
Broadcast("imageLoadResp", message.GetInt(0), message.GetInt(1), message.GetByteArray(2));
break;
by Benjaminsen » March 3rd, 2010, 10:18 am
mindfoolgames wrote:.... The JPEG and PNG encoding from as3corelib could be added just as easily as the bitmap manipulation I did and would provide a much more streamlined solution.
by loucsam » March 3rd, 2010, 11:30 pm
by mindfoolgames » March 4th, 2010, 12:03 am
by loucsam » March 4th, 2010, 10:38 am
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
imageLoader.load(new URLRequest("http://www.mindfoolgames.com/images/layout_jovyInCircleW.jpg"));
connection.addMessageHandler("imageLoadResp", function(m:Message, x:int, y:int, b:ByteArray) {
trace("imageLoadHandler--> " + x + "," + y + " " + b.length);
var bm3:BitmapData = new BitmapData(x,y);
bm3.setPixels(bm3.rect, b);
addChild(new Bitmap(bm3));
})
private function loadComplete(event:Event):void {
var loadedImage:Bitmap = Bitmap(imageLoader.content); // <--------------THIS LINE HERE
var bitmap:BitmapData = loadedImage.bitmapData;
var bytes:ByteArray = bitmap.getPixels(bitmap.rect);
connection.send("imageLoad", loadedImage.width, loadedImage.height, bytes);
}
by loucsam » March 4th, 2010, 11:42 am
by mindfoolgames » March 4th, 2010, 11:03 pm
by mindfoolgames » March 5th, 2010, 12:50 am
import com.adobe.images.JPGEncoder;
var imageLoader:Loader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
imageLoader.load(new URLRequest("http://www.mindfoolgames.com/images/layout_jovyInCircleW.jpg"));
connection.addMessageHandler("imageLoadResp", function(m:Message, b:ByteArray) {
trace("imageLoadHandler--> " size= " + b.length);
var im:Loader = new Loader();
im.loadBytes(b);
addChild(im);
})
private function loadComplete(event:Event):void {
var encoder:JPGEncoder = new JPGEncoder(80);
var rawBytes:ByteArray = encoder.encode(Bitmap(event.target.loader.content).bitmapData);
connection.send("imageLoad", rawBytes);
}
case "imageLoad":
Broadcast("imageLoadResp", message.GetByteArray(0));
break;
by loucsam » March 5th, 2010, 1:23 am