Sign In  Sign Up Live-Chat

Create new image without border

Last post 02-19-2008, 5:25 AM by msfaiz. 1 replies.
Sort Posts: Previous Next
  •  02-18-2008, 7:55 AM 113860

    Create new image without border

    Hi

    I've followed the example shown elsewhere in forums http://www.aspose.com/Community/Forums/thread/104574.aspx in order to swap images in an existing swf and this works pretty well. However I would like to the replacement image without a border. It appears the ShapeManager requires a lineStyle to be added in order to create a rectangle (I get an error {"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"}if I omit the line adding the lineStyle)
    If I create the border with zero width and alpha as follows: shapeManager.Add(new SolidLine(0, new RGB(0, 0, 0, 0))); the border still shows up in the output swf. The only way I've found to suppress the border is to specify a line width of -1. Is there a better way of achieving this?

    Thanks
    Steve
     
  •  02-19-2008, 5:25 AM 113995 in reply to 113860

    Re: Create new image without border

    Attachment: Present (inaccessible)

    Dear Steve,

    To remove border, you will have to set the StyleChangeRecord.LineStyle=-2147483648. I have added few more following lines in the AddImage method.

    --------------------------------------------------------------------------------------

    DefineShape2 defshp = shapeManager.GetDefineShape(shpID);

    StyleChangeRecord scr = defshp.Shape.ShapeList[0] as StyleChangeRecord;

    scr.LineStyle = -2147483648;

     

    flashObjs.Add(defshp);

    --------------------------------------------------------------------------------------

    Here is a complete code that adds an image c:\sunset.jpg without any borders. I have also attached the generated out.swf file.

    --------------------------------------------------------------------------------------

    static void AddImageWithoutBorders()

    {

    FlashContainer flash = new FlashContainer();

    /// set frame rate

    flash.FrameRate = 12.0f;

    /// set frame size

    flash.FrameSize = new Rect(0, 0, 11000, 8000);

    //Add the background colour

    flash.Add(new SetBackgroundColor(new RGB(255, 255, 255, 255)));

    //Add the image without borders

    //Get all the objects needed for adding image in swf file

    ArrayList flashObjs = AddImage(flash.NewIdentifier(), flash.NewIdentifier(), "c:\\sunset.jpg", 500, 500, 5000, 3000);

    flash.Add(flashObjs);

    flash.Write("c:\\out.swf");

    }

    static ArrayList AddImage(int imgID, int shpID, string imageFile, int X, int Y, int Width, int Height)

    {

    ArrayList flashObjs = new ArrayList();

    FlashBitmap bmp = new FlashBitmap(imgID, FlashBitmapType.FlashBitmapJpeg, false, imageFile);

    flashObjs.Add(bmp);

    //Calculate scaling factor

    double scaleX = ((double)Width) / (double)bmp.Width;

    double scaleY = ((double)Height) / (double)bmp.Height;

    //Create a rectangle shape with image as a fill via ShapeManager

    ShapeManager shapeManager = new ShapeManager();

    shapeManager.Add(new SolidLine(1, new RGB(255, 0, 0, 255)));

    shapeManager.Add(new BitmapFill(FillStyleType.NonSmoothedClippedBitmap, imgID, new MatrixTransform(X, Y, scaleX, scaleY)));

    shapeManager.DrawRectangle(X, Y, Width, Height);

    //Add the shape and place it on display list

    DefineShape2 defshp = shapeManager.GetDefineShape(shpID);

    StyleChangeRecord scr = defshp.Shape.ShapeList[0] as StyleChangeRecord;

    scr.LineStyle = -2147483648;

    flashObjs.Add(defshp);

    flashObjs.Add(new PlaceObject2(shpID, 1, 0, 0));

    return flashObjs;

    }


    Many Thanks and Kind Regards,

    Shakeel Faiz
    Support Engineer
    Aspose Tyumen Team
     
View as RSS news feed in XML