• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Tdawg30

Reducing Bitmap Object size

8 posts in this topic

Hey, just wondering is there anyway of reducing the size of a bitmap object(space on the disk, not dimensions) before I save it to disk? I have a program which is accepting images as input, changing the RGB values of the image, and then outputting the new image, the problem is the outputted image always takes up more memory than the original image even though if I am not adjusting its dimensions in anyway.

Google searches typically turn up information regarding dimensions and not disk space. Any information on handling images in a different fashion or reducing the space of a bitmap object would be appreciated.
0

Share this post


Link to post
Share on other sites
You are probably changing the bitmap's color depth (e.g. reading it as a RGB image (96 bits per pixel) and writing it back as a RGBA image (128 bits per pixel)). Did you check that? This is my best guess.

As for reducing file size in general, bitmaps are often highly compressible. You could compress the file before saving it to disk and decompress it before reading it. Bitmap doesn't offer much support in this direction, so you may have to use an external library to perform the compression. Or you could use PNG's instead which natively support compression.
0

Share this post


Link to post
Share on other sites
Thanks for the reply Bacterius,

How would I check if I am writing it back as an RGBA image? I am creating new pixel colors using the Color.FromArgb() method, and saving the image using the Bitmap Class' save() method
0

Share this post


Link to post
Share on other sites
Just check the bitmap's type in the file's properties (or check the file size - if the file size changes according to a 3:4 ratio it's almost certain this is what's happening). As for saving in the correct format, you want to change the bitmap's pixelformat before saving it (I assume - I've never used the BItmap class in C# but the terminology is standard across most languages):

http://msdn.microsoft.com/en-us/library/system.drawing.image.pixelformat.aspx

So for a 24-bit RGB image you will want the PixelFormat.Format24bppRgb one probably. My guess is the bitmap reverted to RGBA format as you wanted to set alpha channels (otherwise it shouldn't have changed).
1

Share this post


Link to post
Share on other sites
You are right, the original image that was read came in the format of 24bppRgb, however the one being outputted is 32bppArgb. The problem is the original image is actually being read from a pdf file of the size ~110 kb, and the bitmap object that is being outputted is around 2mb!! obviously the problem isn't limited to the pixel format, however this a start in the right direction.

Thank you for your help.
1

Share this post


Link to post
Share on other sites
The bitmap could be compressed, which would explain the huge size difference. The bitmap "specification" does allow for compression to take place (there's a field for it in the header but I've personally never seen it used). Perhaps the Bitmap class provides a wrapper or some sort of interface to do the same thing, but I wouldn't know that much :)
0

Share this post


Link to post
Share on other sites
The pdf is obviously compressed. When you read the bmp off the PDF, you read it uncompressed, and then save it as such. In general, a RAW BMP, even using 24 bpp, will be width*height*3 bytes large. Using that, you will find the minimum size you will be output using 24bpp with no compression.

If you want compression, there's 2 options: #1, using BMP's built in compression technique, which is Run Length Encoding (RLE), and not the best (google it if you want). Or,
#2, use an external library to compress the image into another format (PNG, for example), and save that.
0

Share this post


Link to post
Share on other sites
There's also the option of using his own compression on a normal BMP file. Huffman coding would likely provide decent compression compared to RLE, and is not terribly difficult to program.
0

Share this post


Link to post
Share on other sites
[quote name='bobbias' timestamp='1337097008' post='4940443']
There's also the option of using his own compression on a normal BMP file. Huffman coding would likely provide decent compression compared to RLE, and is not terribly difficult to program.
[/quote]

But then it wouldn't be a BMP, it would be his own format. And he would need a special program to open it. I'm assuming he wants to keep it within the bounds of a popular image standard, thus, RLE in a BMP (which is supported in the BMP header), or using PNG (or some other format if he chooses) Edited by BeerNutts
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0