如何使用Flash BitmapData在不损失质量的情况下放大图像?

发布于 2024-08-03 03:20:21 字数 679 浏览 6 评论 0原文

我正在尝试在 Flash 中放大图像而不使其像素化,我知道我会失去一些质量 通过扩大规模,但我并不想扩大 6 倍或其他什么:)

我尝试使用矩阵和规模,但质量很差......还有其他方法可以做到这一点吗?


所以这是我的代码,

var _bmpData:BitmapData = new BitmapData( stage.stageWidth, stage.stageHeight, true, 0x00000000 );
var _scale:Number = Math.max(stage.stageWidth/_imageLoad.contentAsBitmap.width, stage.stageHeight/_imageLoad.contentAsBitmap.height)
var _matrix:Matrix = new Matrix();
_matrix.scale(_scale, _scale);

_bmpData.draw( _imageLoad.contentAsBitmap, _matrix, null, null, null, true);

var _bmp:Bitmap = new Bitmap( _bmpData, 'always', true );

问题是,如果我不使用矩阵,一切都很好并且不会像素化,但是如果我使用矩阵进行缩放,它就会像素化......有什么方法可以解决这个问题吗?谢谢

I'm trying scale up an image in Flash without making it pixelated, I know that I will loose some quality
by scaling up, but i'm not trying to scale 6 times bigger or something :)

I tried to use matrix and scale, but the quality is just bad... is there any other ways to do this?


so here's my code,

var _bmpData:BitmapData = new BitmapData( stage.stageWidth, stage.stageHeight, true, 0x00000000 );
var _scale:Number = Math.max(stage.stageWidth/_imageLoad.contentAsBitmap.width, stage.stageHeight/_imageLoad.contentAsBitmap.height)
var _matrix:Matrix = new Matrix();
_matrix.scale(_scale, _scale);

_bmpData.draw( _imageLoad.contentAsBitmap, _matrix, null, null, null, true);

var _bmp:Bitmap = new Bitmap( _bmpData, 'always', true );

The thing is that if I dont use matrix, everything's fine and not pixelated, but if I use matrix to scale, it's pixelated.... is there any way to fix this? thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

櫻之舞 2024-08-10 03:20:21
var myBitmap : Bitmap = new Bitmap(myBitmapData);
myBitmap.smoothing = true;

您还可以查看BitmapData类的draw方法,该方法有一个平滑参数。显然,这无助于解决压缩图像的固有问题,但可能会稍微缓解这些问题。

var myBitmap : Bitmap = new Bitmap(myBitmapData);
myBitmap.smoothing = true;

You can also look at the draw method of the BitmapData class, which has a smoothing parameter. Obviously this isn't going to help with the inherent issues of upresing an image, but it might mitigate them slightly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文