This content has been marked as final. Show 11 replies
Hi there, i am looking for the same.. a class to resize images.
I have found the following.. maybe we can help eachother and create a neat class.
resize image class
smoothing an image
Greetz, and let me know if you created a cool class
i've moved on a while ago.. i think i actually found a simple answer but moved my project to C#. i also had the need for my program to respect color profiles (sRGB, adobe RGB) which flex was not doing. i didn't have the same problems in c#/WPF
Well... very very strange !!
I made some more test and I can't get anymore the better image resizing quality !!!!
I didn't change anything to the code.
If I didn't have made some screenshots I should think it was a dream !!
May be somebody has an explanation ????
hi jylaxx, how did you resize your image?
did you use the resize image class?
maybe does flex3 set smoothing at true standard...
the problem i have is that i want to resize an 900kb image to an 100kb image, so i can save more images in my folder.
with the image resize class i mentioned the image gets resized, but i get the feeling my image is still 900kb..
I am doing resizing to create a thumbnail of the opened modules of my app :
var bmpData : BitmapData = new BitmapData( module.width, module.height, false, 0xe4e4e4 ) ;
bmpData.draw( module ) ;
var m : Matrix = new Matrix() ;
m.scale( canvas.width / module.width, canvas.height / module.height ) ;
canvas.graphics.beginBitmapFill( bmpData, m, false, true ) ;
canvas.graphics.drawRect( 0, 0, canvas.width, canvas.height ) ;
I wrote this code when I start using Flex so may be a better solution exists.
Anyway I made a mistake about the difference of Flex2 and Flex3 rendering ! I made the link because I notice the difference at the time I test Flex3...
In fact the smoothing difference come from the size (proportion?) of the image. Just few pixels difference make the quality very different. I am doing more investigations...
Your image is coming from where ? Is-it a local file ?
I am not able to get a local file directly to flash player; I have to upload it and then get it back from the server.
May be you are using AIR ?
yep i am using air..
otherwise i would push my selected image trough some php, save it on the server and load it again in the application.
this because i know how to get a smaller image in php :)
in air i want to save the image into a blob and push it into the local sqlite database that goes with air.
To prevent extreme sizes of my database i want to resize the image to the size i need.
U use a matrix.. do you redraw your image? maybe thats the trick i need.. redraw a tempimage and save that tempimage.. hmmz.. pretty difficult for a beginner like me :D
The Matrix is scaling the bitmap and then the scaled bitmap is drawn with the graphics methods.
The most difficult is to find the trick... so now it is easy !
with the previous answers i created a full working image resize for flex 3(air)
perhaps the solution i have made could be simplified, but it works.. and thats what it's all about isn't it?
Download here the example files for resize and locally store the image.: (flex 3 air example)
see if you like it..
I also created a solution to save the image into the sqlite database that goes with air.
I found my one solution by encoding it to a base64 string and store it into the db.
Here a link to the topic with the solution.
link to the topic with my solution
The actual saving into the db is not there, but if you'd ask I'm happy to give you that also.
And again another example.
This example shows how you can select a local image, resize it and save the thumbnail into the application storage directory.
Here the link to that topic:
Image select, resize and save example