a difficult XNA question

Discussion in 'Game Development (Technical)' started by Jack Norton, Aug 10, 2009.

  1. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    Not sure if anyone knows how to do this (or even IF is possible) but in practice: I have PNG images which I have converted to two JPGs, alpha and color, to save space (I save over 50% on disk space with it).
    Simple question: there's any way to load them as a Texture2D to use them in XNA?
     
  2. luggage

    Moderator Original Member Indie Author

    Joined:
    Jul 27, 2004
    Messages:
    2,132
    Likes Received:
    0
    Your best best is to look at custom content importers for that. A neat use for it with your system would be to add the PNG to your workspace and specify your own importer (it can have custom attributes for JPG compression quality per asset etc).

    Your importer would take the PNG and split off the JPG's and write them out as a binary file (or two). On load you'd pull in the binary files, create a texture2d and write the data to the texture manually.

    I'm not sure if it would be worthwhile in the end though. You can set texture compression on any PNG's you add I believe and also the packager will also compress things.
     
  3. ChrisP

    Indie Author

    Joined:
    Feb 5, 2007
    Messages:
    971
    Likes Received:
    0
    It may be worth it for photorealistic art, since that's where JPEG's lossy compression really shines. Even the best lossless compression has a really hard time matching the savings you can get from smart use of lossy compression. Just depends on the context as to which is the better choice.

    Not an answer to your question, but are you sure you want JPEG artefacts in your transparency? :) Using a PNG for the alpha channel sounds like a better idea, especially since most alpha channels in practical use (e.g. for sprites) are more or less composed of large continuous "white"/"black" areas, which is a situation that PNG is designed to work well for.
     
  4. Junkyard Sam

    Junkyard Sam New Member

    Joined:
    May 11, 2009
    Messages:
    292
    Likes Received:
    0
    His problem with PNG, I think, is that you either get 8bit/1bit alpha or 24bit/8bit alpha. So you choose between a hard edge alpha or an unnecessarily huge image. =(

    There's no standard image format with a happy middle ground, like 8bit/4bit, etc.

    Maybe this is a dumb question, but would DXT3/DXT5 work with XNA for what you need?
     
  5. Sol_HSA

    Indie Author

    Joined:
    Feb 27, 2005
    Messages:
    470
    Likes Received:
    1
    so.. 24bit jpeg color, 8bit png alpha?
     
  6. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    Ehm, well I asked because I used that system in Renpy, but was a ready-made script. I know really little about DX and D3D in particular, so was just asking if there was a quick system/command that I ignore.
    Otherwise will just use PNGs, the game size should still be low compared to some XNA demos of 500Gb :eek:
     
  7. jamesm

    jamesm New Member

    Joined:
    Jul 28, 2008
    Messages:
    48
    Likes Received:
    0
    Do you mean 500mb ;)
     
  8. Jack Norton

    Indie Author

    Joined:
    Jul 28, 2004
    Messages:
    5,130
    Likes Received:
    0
    Yeah, I mean 500mb LOL
     

Share This Page

  • About Indie Gamer

    When the original Dexterity Forums closed in 2004, Indie Gamer was born and a diverse community has grown out of a passion for creating great games. Here you will find over 10 years of in-depth discussion on game design, the business of game development, and marketing/sales. Indie Gamer also provides a friendly place to meet up with other Developers, Artists, Composers and Writers.
  • Buy us a beer!

    Indie Gamer is delicately held together by a single poor bastard who thankfully gets help from various community volunteers. If you frequent this site or have found value in something you've learned here, help keep the site running by donating a few dollars (for beer of course)!

    Sure, I'll Buy You a Beer