• 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
cbreiny

Pygame Image Problem

8 posts in this topic

I've been working on the HUDs for my game, more specifically the Health, Mana, and XP bars that will be displayed at the bottom of the screen. So I drew up an image in photoshop for the health bar that looks like this:

[img]http://3.bp.blogspot.com/-1kC9Bem86xk/UDj44cTufbI/AAAAAAAAAMM/UF4uhW-a5QY/s1600/Screen+shot+2012-08-25+at+10.03.10+AM.png[/img]

But for some reason the in-game image looks like this:

[img]http://2.bp.blogspot.com/-V6FVtEAULFk/UDj45YW5RfI/AAAAAAAAAMU/hdJ-SDBjqO4/s1600/Screen+shot+2012-08-25+at+9.50.17+AM.png[/img]

As you can tell it is does not match the correct one, and its a little frustrating because in-game it looks too dull. I'm not sure why Pygame is doing this? I'm using the very standard pygame functions to load and render the image:
[CODE] pygame.image.load('image_path').convert() [/CODE] and [CODE] surface.blit(hp_image, (position.x, position.y)) [/CODE]

Now that I've noticed it, it's actually doing it to a lot of my images! If anyone knows why, please let me know. Thanks in advance!
0

Share this post


Link to post
Share on other sites
Are you mistakenly creating the window with a color-depth (or bits per pixel, bytes per pixel) less than 8 bits per color channel?
How do you create your window?

Are you mistakenly altering the transparency/alpha-component of the images?
Change the background color to bright pink and then see if that effects the color of the rendered image - if it does, it probably has some accidental transparency.

Both the images you posted above are from the same computer right? One is the actual image, and the other is an actual screenshot of the actual image as seen in the game?
1

Share this post


Link to post
Share on other sites
[quote name='Servant of the Lord' timestamp='1345912990' post='4973272']
Are you mistakenly creating the window with a color-depth (or bits per pixel, bytes per pixel) less than 8 bits per color channel?
How do you create your window?

Are you mistakenly altering the transparency/alpha-component of the images?
Change the background color to bright pink and then see if that effects the color of the rendered image - if it does, it probably has some accidental transparency.

Both the images you posted above are from the same computer right? One is the actual image, and the other is an actual screenshot of the actual image as seen in the game?
[/quote]

Yes, both images are from the same computer, the brighter image is the actual, the duller one is a screenshot of what pygame is doing. I did change the background color to bright pink to check from any transparency mistakes, that's also not the issue. It does the same thing! [img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] And this is how I'm creating my window:
[CODE]
screen = pygame.display.set_mode(resolution)
[/CODE] Edited by breinygames
0

Share this post


Link to post
Share on other sites
What image format is the original picture? Have you tried changing that? I've found that bitmap images are affected less by pygame's convert().
1

Share this post


Link to post
Share on other sites
[quote name='Esys' timestamp='1345914250' post='4973279']
What image format is the original picture? Have you tried changing that? I've found that bitmap images are affected less by pygame's convert().
[/quote]

The image is .png just like all my other images I've been using. I tried re-saving the image to .jpg, and .bmp with 8, 16, 24 and 32 color depths each. I've tried so many different things! Haha. Nothing is working!
0

Share this post


Link to post
Share on other sites
Well, I no longer think it's the wrong bit depth, because the pixels of your wrong image are actually being changed to different colors (they gain some blue and green, and lose some red), not just rounded to the next closest bit depth.

Samples: (original colors -> wrong colors)
[b](218, 0, 0) -> (172, 32, 11)
(179, 0, 0) -> (140, 27, 10)
(0, 0, 0) -> (0, 0, 0)
(38, 0, 0) -> (34, 4, 0)[/b]

It really looks like something transparent is being drawn over the images, or that the image is transparent and being drawn over something else. Try eliminating every other draw call except for this image being drawn and the surface being filled a solid non-black color. Try (0, 0, 255) to see if the resulting image spikes in blue. Edited by Servant of the Lord
1

Share this post


Link to post
Share on other sites
Let me guess. You are using a Mac.
This is a bug in the apple-provided png-loading routines that pygame uses on macs.
AFAIK this has been fixed in current versions of pygame, you should get a newer version for your system.
2

Share this post


Link to post
Share on other sites
[quote name='Steveway' timestamp='1345915033' post='4973284']
Let me guess. You are using a Mac.
This is a bug in the apple-provided png-loading routines that pygame uses on macs.
AFAIK this has been fixed in current versions of pygame, you should get a newer version for your system.
[/quote]

Yep, I just figured this out. When I open the image back in photoshop instead of opening it using the standard 'Adobe RGB (1998)' color profile, I tried opening it in the 'Apple RGB' color profile and opened the image EXACTLY how it looks in-game. So I guess it has to do with how pygame loads the images on Mac, the problem is I have the most updated version of Pygame. Not sure how to fix it now :/ Edited by breinygames
0

Share this post


Link to post
Share on other sites
When you initialise the screen variabile do it like this

[source lang="python"]screen = pygame.display.set_mode((ScreenWidth,ScreenHeight),0,32)[/source]
If this doesn't work try to remove the .convert from the image loading function and replace it with convert_alpha (so it retains its transparency).If even that doesn't work make your own image loading function and dump Pygame's
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