I want to be precise, so if an explainton is needed about that, visit this page
My question: Is there any way to apply Scale2x (or its derivates) automatically (with a plug-in or a javascript) or I should stop trying and resignate to do it manually?
Thanks beforehand.
Here is a script adaptation of the scale2x algorithm:
var image = Document.RasterImage;
var sizeX = image.sizeX;
var sizeY = image.sizeY;
// create copy of the image with border pixels duplicated
var timg = Blender.CreateCanvas(sizeX+2, sizeY+2, 0);
Blender.Compose(timg, 1, 1, sizeX+1, sizeY+1, image, 0, 0, 0, Blender.OpSrc);
Blender.Compose(timg, 0, 1, 1, sizeY+1, image, 0, 0, 0, Blender.OpSrc);
Blender.Compose(timg, 1, 0, sizeX+1, 1, image, 0, 0, 0, Blender.OpSrc);
Blender.Compose(timg, sizeX+1, 1, sizeX+2, sizeY+1, image, sizeX-1, 0, 0, Blender.OpSrc);
Blender.Compose(timg, 1, sizeY+1, sizeX+1, sizeY+2, image, 0, sizeY-1, 0, Blender.OpSrc);
timg.SetPixel(0, 0, 0, 0, timg.GetPixel(1, 1, 0, 0));
timg.SetPixel(0, sizeY+1, 0, 0, timg.GetPixel(1, sizeY, 0, 0));
timg.SetPixel(sizeX+1, 0, 0, 0, timg.GetPixel(sizeX, 1, 0, 0));
timg.SetPixel(sizeX+1, sizeY+1, 0, 0, timg.GetPixel(sizeX, sizeY, 0, 0));
// double the size of the canvas of the original image
image.Resize(sizeX*2, sizeY*2, 1, 1, 0, 0, 0, 0);
// apply scale2x
for (var y = 0; y < sizeY; ++y)
{
for (var x = 0; x < sizeX; ++x)
{
var B = timg.GetPixel(x+1, y, 0, 0);
var D = timg.GetPixel(x, y+1, 0, 0);
var E = timg.GetPixel(x+1, y+1, 0, 0);
var F = timg.GetPixel(x+2, y+1, 0, 0);
var H = timg.GetPixel(x+1, y+2, 0, 0);
if (B != H && D != F)
{
image.SetPixel(x*2 , y*2 , 0, 0, D == B ? D : E);
image.SetPixel(x*2+1, y*2 , 0, 0, B == F ? F : E);
image.SetPixel(x*2 , y*2+1, 0, 0, D == H ? D : E);
image.SetPixel(x*2+1, y*2+1, 0, 0, H == F ? F : E);
}
else
{
image.SetPixel(x*2 , y*2 , 0, 0, E);
image.SetPixel(x*2+1, y*2 , 0, 0, E);
image.SetPixel(x*2 , y*2+1, 0, 0, E);
image.SetPixel(x*2+1, y*2+1, 0, 0, E);
}
}
}
Go to Effect->Custom operation... and paste the above code there replacing the original. If you want to use the custom operation icon on the toolbar, you may also want to comment out the code in the Configuration tab.
I know how to use custom operations, so that last explaintion isn't necessary.
But I am VERY thankful for this, it will save me a lot of work.
Thanks again, Vlasta!
Find out how Vista icons differ from XP icons.
See how RealWorld Icon Editor handles Vista icons.