The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

Results 1 to 6 of 6

Thread: JPEGENcoder with text

  1. #1
    11
    posts
    Registered User

    JPEGENcoder with text

    Hi all,

    I'm trying to take a 'snapshot' of a Sprite that I've drawn lots of graphics over, and added Texts and other Sprites to.

    I've been using JPEGEncoder to do this and it's now working fairly well*, but the TextFields I've been adding to the Sprite are showing up as twice the size on the JPEG snapshot

    (the TextFields use TextFormats btw)

    Does anyone know why this would be?

    thanks
    Henry

    * one thing to watch out for, when doing this, is when you draw your Sprite to the BitmapData, the registration can be assumed to be the centre, so you have to send the appropriate Matrix to the BitmapData.draw() method. Then do the Jpeg Encoding

  2. #2
    1,596
    posts
    Holosuite User
    That certainly has nothing to do with the encoder since it processes a bitmap, so it's too late to manipulate the particular parts of the image, it's already "flat". If you were changing the values in the transformation matrix, I'd look there again the solution should be around that place somewhere

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

  3. #3
    11
    posts
    Registered User
    Many thanks - will do - though I think the transformation I've done is just on position, not size (I haven't done the maths of this stuff for 18 years, lol)

    var r:Rectangle = this.getBounds(this);
    ..
    SourceBitMap.draw(this, new Matrix(1,0,0,1,-r.left,-r.top));

  4. #4
    1,596
    posts
    Holosuite User
    Erm... what does this.transform.matrix trace? how text field relates to "this"?

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

  5. #5
    11
    posts
    Registered User
    Quote Originally Posted by wvxvw View Post
    Erm... what does this.transform.matrix trace? how text field relates to "this"?
    sorry, "this" is the Sprite on which everything is drawn and some sprites and textboxes are added so

    Code:
    mainSprite.addChild(textFieldInstance);
    mainSprite.addChild(otherSprite);
    
    mainSprite.graphics.beginFill(..);
    ...
    mainSprite.graphics.endFill();
    
    
    var r:Rectangle = mainSprite.getBounds(mainSprite);
    
    var SourceBitMap:BitmapData = new BitmapData();
    SourceBitMap.draw(mainSprite, new Matrix(1,0,0,1,-r.left,-r.top));
    ..would be more like it, though this is reduced down from what I've got - that's the gist of it. It seems to work ok from a method within the extended-Sprite - hence the "this" in the code above.
    Last edited by Hzle; May 18th, 2011 at 04:53 AM.

  6. #6
    1,596
    posts
    Holosuite User
    I was actually wondering if this.transform.matrix is scaled, or, if not, then what would be the ratio of text field's scale to "this", or the parent of "this", and if this by chance overrides some scale-related properties / is captured by Transform object or something of that kind.

    I support FlashDevelop (the .NET open source editor for Flash and web developers)
    couchsurfing if you need it

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012