Can I dynamically generate a 300 dpi image from a flash file?
-
13-09-2019 - |
Question
I'm using a compination of actionscript's getPixel and php's imagecreatetruecolor and imagesetpixel to generate a png image of an swf movie inside a browser.
At the moment it will output a 72 dpi image at the same resolution as the swf movie, but I've been asked about the possibility of generating a 300 dpi image instead.
Is this possible?
Solution
Flash doesn't really know anything about resolution or dpi. The only way to output an image from flash with the correct amount of pixels and at print quality is to scale your movie to that amount of pixels and use print quality images or vector graphics. Otherwise you're just going to have a programatically scaled image which is no better than just sending the 72dpi image off to print. Long story short, flash is not a good print design platform.
OTHER TIPS
I assume you use BitmapData.draw
to generate the image? If you scale the swf up (scaleX
and scaleY
) before dumping the image to a BitmapData
, you can get a higher sample rate = a higher DPI.
If you don't want more data, just interpolation (like McWafflestix suggests), you can try using a scale Matrix
as the second parameter to draw
.
Yes, it should be possible. You can either reduce the size of your output image (thereby increasing the DPI) or use interpolation to increase the effective resolution from 72 DPI to 300 DPI.
yes you can, i not sure about flashplayer 9, but i think it works there
Here is my solution, maybe is bad, or stupid codding, but it works
all you need is to play with each item that you need to make at 300 dpi some kind of
for(...)
{
var item:* = items[i]
item.x = item.x * delta_dpi
item.y = item.y * delta_dpi
item.width = item.width * delta_dpi
item.height = item.height * delta_dpi
if(item is TextArea)
// here you must increase sizes for text
[your_text_size] = [your_text_size] * delta_dpi
// and you need to apply new size to your area
----------
// in my case i used this function
if(item is TextArea)
item.htmlText = remakeText(item.htmlText)
}
function remakeText():String
{
var arr:Array = str.split('SIZE="')
var str:String
var i:int;
for(i=1; i < arr.length; i++)
{
str = arr[i]
var idx:int = str.indexOf('"')
var str2:String = str.substr(0, idx)
var nr:Number
if(to300)
nr = Number(str2) * 3.125
else
nr = Number(str2) / 3.125
str = 'SIZE="' + nr + str.substring(idx)
arr[i] = str
}
str = ''
for(i=0; i < arr.length; i++)
str += arr[i]
return str
}