smilewithYash
asked on
convert Sprite and its children in to bitmap for print
Hello All,
I am new to flex. so please excuse me if i ask some silly things. But I am making an drawing application where i required my sprite to be in print.
In application there is two mode in printing
1. Full Mode
2> Multiple mode
In full mode i have to print sprite (that contain all the drawing object in it)only one time.But in multiple mode i have to make multiple times in desired size on single page.From here my problem start.
Right now i am using alivePDF for converting my sprite in to pdf format and then i send that converted pdf to php page.I have to use only PHP as it is client requirement.
For Multiple Printing I use SNAPSHOT in flex to capture my sprite and its Contain t but then when i create its pdf its distort or not show images in exact mean.
I used matrix scale function to resize my bitmap data which i get from SNAPShot.
Is there any way to do such thing.??
I am new to flex. so please excuse me if i ask some silly things. But I am making an drawing application where i required my sprite to be in print.
In application there is two mode in printing
1. Full Mode
2> Multiple mode
In full mode i have to print sprite (that contain all the drawing object in it)only one time.But in multiple mode i have to make multiple times in desired size on single page.From here my problem start.
Right now i am using alivePDF for converting my sprite in to pdf format and then i send that converted pdf to php page.I have to use only PHP as it is client requirement.
For Multiple Printing I use SNAPSHOT in flex to capture my sprite and its Contain t but then when i create its pdf its distort or not show images in exact mean.
I used matrix scale function to resize my bitmap data which i get from SNAPShot.
Is there any way to do such thing.??
Also you can merge images when you are using multiple SNAPSHOT option
The following example creates two BitmapData objects. Both are 100 x 80 pixels in size. The first is filled with green and the second is filled with red. The code calls the merge() method, merging the second BitmapData pixels into the first BitmapData object, but only on a specified rectangular area:
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
var bmd1:BitmapData = new BitmapData(100, 80, true, 0xFF00FF00);
var bmd2:BitmapData = new BitmapData(100, 80, true, 0xFFFF0000);
var rect:Rectangle = new Rectangle(0, 0, 20, 20);
var pt:Point = new Point(20, 20);
var mult:uint = 0x80; // 50%
bmd1.merge(bmd2, rect, pt, mult, mult, mult, mult);
var bm1:Bitmap = new Bitmap(bmd1);
addChild(bm1);
var bm2:Bitmap = new Bitmap(bmd2);
addChild(bm2);
bm2.x = 110;
The following example creates two BitmapData objects. Both are 100 x 80 pixels in size. The first is filled with green and the second is filled with red. The code calls the merge() method, merging the second BitmapData pixels into the first BitmapData object, but only on a specified rectangular area:
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Rectangle;
import flash.geom.Point;
var bmd1:BitmapData = new BitmapData(100, 80, true, 0xFF00FF00);
var bmd2:BitmapData = new BitmapData(100, 80, true, 0xFFFF0000);
var rect:Rectangle = new Rectangle(0, 0, 20, 20);
var pt:Point = new Point(20, 20);
var mult:uint = 0x80; // 50%
bmd1.merge(bmd2, rect, pt, mult, mult, mult, mult);
var bm1:Bitmap = new Bitmap(bmd1);
addChild(bm1);
var bm2:Bitmap = new Bitmap(bmd2);
addChild(bm2);
bm2.x = 110;
ASKER
thanks for reply dgofman
ya actually i tried this thing.i add with for loop and also for specifying margins between sprite.But when i print them they didn't appear as they look on screen.
for explaining things: Like i am drawing a rectangle element with boarder around it and then when i go for multi print on some boarder comes right and for some it vanished from left side or from rightside.
i searched over net ..............there i find that snapshot draw bitmap in low dpi ...so i was thinking that may be the problem.??
ya actually i tried this thing.i add with for loop and also for specifying margins between sprite.But when i print them they didn't appear as they look on screen.
for explaining things: Like i am drawing a rectangle element with boarder around it and then when i go for multi print on some boarder comes right and for some it vanished from left side or from rightside.
i searched over net ..............there i find that snapshot draw bitmap in low dpi ...so i was thinking that may be the problem.??
PLease can you attach your sample I will review and fix it
ASKER
Ya Sure....i can let you see wat happening in my application.
plz look for demo http://demo.b24solutions.com/flex/adobeflex/planetLabel.html.....there you will find print section on single label mode.then you can see what i want to say....
plz look for demo http://demo.b24solutions.com/flex/adobeflex/planetLabel.html.....there you will find print section on single label mode.then you can see what i want to say....
ASKER
Plz delete ".....there" from above url
original one is
http://demo.b24solutions.com/flex/adobeflex/planetLabel.html
plz login with a@a.com and 1234.
original one is
http://demo.b24solutions.com/flex/adobeflex/planetLabel.html
plz login with a@a.com and 1234.
Can you give me steps for reporoducing your problem?
Did you try to use http://alivepdf.bytearray.org/ its very good quality of SNAPHOTS images
ASKER
actaully i am using this currently..
ok here are steps
login with the user name and password ..........
1>select first option that is used default templates.
click continue
2> select page size rectangle 11X8.5
click continue
3> select single mode.
4> draw anything so you can chk
now click on print.........select print preciew then you will see the problem
hoping for quick reply
ok here are steps
login with the user name and password ..........
1>select first option that is used default templates.
click continue
2> select page size rectangle 11X8.5
click continue
3> select single mode.
4> draw anything so you can chk
now click on print.........select print preciew then you will see the problem
hoping for quick reply
So, you want a single image print (one page) am I right\?
ASKER
Ya as you see there is difference between images .....i don't know why this hapeening.
if(templateHeight == templateWidth)
{
if(HOL)
{
for(var j:Number = 0;j< WCount ; j++)
{
for(var i:Number = 0;i< HCount ; i++)
{
backgroundLayer.graphics.b eginFill(s hapeColor, 1);
backgroundLayer.graphics.m oveTo(temp MarginH,te mpMarginV) ;
backgroundLayer.graphics.d rawRoundRe ct(backX+t empMarginH ,backY+tem pMarginV,r ecV,recH,a ctualRadiu s);
addElementToo(tempMarginH, tempMargin V);
backgroundLayer.graphics.e ndFill();
tempMarginH = marginH + tempMarginH + recV;
}
tempMarginV = marginV + tempMarginV + recH;
tempMarginH = marginH;
}
}
}
here backgroundLayer work as a final view of design (when single label mode converted to multiple mode)
here is the code for addelementtoo()
var bitmapData:BitmapData = ImageSnapshot.captureBitma pData(laye rContainer );
var matrix:Matrix = new Matrix();
matrix.transformPoint(new Point(bitmapData.width/2,b itmapData. height/2)) ;
matrix.scale(1/WCount,1/HC ount);
var bitmapDat:BitmapData = ImageSnapshot.captureBitma pData(laye rContainer ,matrix);
var bitmap:Bitmap = new Bitmap(bitmapDat,PixelSnap ping.ALWAY S,true);
backgroundLayer.addChild(b itmap);
now this final backgroundLayer is send to alivepdf where it is converted as pdf and shown for print.
plz help......i have no idea what i was doing wrong here
if(templateHeight == templateWidth)
{
if(HOL)
{
for(var j:Number = 0;j< WCount ; j++)
{
for(var i:Number = 0;i< HCount ; i++)
{
backgroundLayer.graphics.b
backgroundLayer.graphics.m
backgroundLayer.graphics.d
addElementToo(tempMarginH,
backgroundLayer.graphics.e
tempMarginH = marginH + tempMarginH + recV;
}
tempMarginV = marginV + tempMarginV + recH;
tempMarginH = marginH;
}
}
}
here backgroundLayer work as a final view of design (when single label mode converted to multiple mode)
here is the code for addelementtoo()
var bitmapData:BitmapData = ImageSnapshot.captureBitma
var matrix:Matrix = new Matrix();
matrix.transformPoint(new Point(bitmapData.width/2,b
matrix.scale(1/WCount,1/HC
var bitmapDat:BitmapData = ImageSnapshot.captureBitma
var bitmap:Bitmap = new Bitmap(bitmapDat,PixelSnap
backgroundLayer.addChild(b
now this final backgroundLayer is send to alivepdf where it is converted as pdf and shown for print.
plz help......i have no idea what i was doing wrong here
ASKER
anyOne Plz Help me out......Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for help....this really helps but i have to use bitmap api as my application have masking on labels and i have to prit only label no additional things.
this is the client requirement.......earlier i was trying snapshot .......but now i am using bitmap draw method it gives me pleasing result not accurate though........working on this .............
this is the client requirement.......earlier i was trying snapshot .......but now i am using bitmap draw method it gives me pleasing result not accurate though........working on this .............
Any way you can control size of your bitmap data by using BitmapData class
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/BitmapData.html
http://livedocs.adobe.com/flex/3/html/help.html?content=Working_with_Bitmaps_07.html