Welcome to TalkGraphics.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    472

    Question PNG export question

    Hi

    Draw a square, 30 x 30 pixels with no line and no effects, and colour it red (size and colour are irrelevant, this is just as an example).

    Export it as a PNG and then look at the PNG - it will consist of more than just the red I chose, there are several shades of red in there as well. Why is this?

    It's causing me a problem because I created a simple coloured square with a dot in it to act as a tiled website background but these 'extra' colours mean I do not get an even background colour.
    IP

  2. #2
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: PNG export question

    Quote Originally Posted by gpholman View Post
    Export it as a PNG and then look at the PNG - it will consist of more than just the red I chose, there are several shades of red in there as well. Why is this?
    This is because of anialiasing. If your rectangle is not pixel aligned and it's size is not whole pixels number it will have antialiasing frame.
    To avoid it, simply make it pixel aligned and with even size. Just make sure all these numbers are integer:
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	pixels.png 
Views:	158 
Size:	7.0 KB 
ID:	58119  
    John.
    IP

  3. #3
    Join Date
    Feb 2009
    Location
    UK
    Posts
    472

    Default Re: PNG export question

    Fantastic - fixed!

    Cheers
    IP

  4. #4
    Join Date
    Aug 2008
    Location
    Canton, GA
    Posts
    666

    Default Re: PNG export question

    Would be handy to be able to snap this to the grid and have that force to pixel alignment. Even with snap options set to 10pix majors with 10 subdivisions, grid showing, and snap to grid selected, I'm still able to move and size objects to non-integer points.

    If not a function of the grid, there could be a simple "round up" option or something - maybe next to the Position and Size boxes - allowing you to select an object and click the round up button.

    I know I sound lazy, cause it's not like it's hard to make the changes, but if you have a lot of objects, that's possibly 4 manually fixed values * number of objects, where at least two clicks would be quick and brainless to get the same result.
    IP

  5. #5
    Join Date
    Aug 2004
    Location
    Ukraine
    Posts
    3,904

    Default Re: PNG export question

    When you have a grid set, only proportional scaling (draginng the corner blob) can change size in fractional pixels. This can't be avoided if we want a smooth scaling. If you don't do it, all other transformations seems to produce only whole pixels.
    John.
    IP

  6. #6

    Default Re: PNG export question

    Don't worry about all that.
    Just export your 30x30 shape as a 256 colour PNG and delete that extra antialiased colour from the palette.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	export_256.png 
Views:	132 
Size:	12.6 KB 
ID:	58140  
    Attached Images Attached Images  
    IP

 

 

Bookmarks

Posting Permissions

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