Hot answers tagged image
102
"Memory" and "efficiency" are commonly misused terms, so I'll give you an answer for four different elements that may affect the performance of your game.
I will be oversimplifying way too many things to keep it short and concise, but there are tons of inaccuracies in this text below, so take it with a pinch of salt. However, the main concepts should be ...
22
Here are the “restored” images, thanks to tillberg's further research:
As expected, there is a 5-byte block marker every about 0x4020 bytes. The format appears to be the following:
struct marker {
uint8_t tag; /* 1 if this is the last marker in the file, 0 otherwise */
uint16_t len; /* size of the following block (little-endian) */
uint16_t ...
18
Based on Sam's suggestion, I forked James' code at https://github.com/tillberg/skyrim and was able to successfully extract n_letter.png from the Skyrim Textures BSA file.
The "file_size" given by the BSA headers is not the actual final file size. It includes some header info as well as some random chunks of useless-seeming data scattered around.
The ...
16
Once an image is loaded off the disk and is formatted for rendering, it will use the same amount of memory regardless of whether that image was saved to disk using PNG, JPEG, or GIF.
General rule of thumb: JPEG is a lossy format, and will degrade image quality in order to make the image smaller on disk. PNG, on the other hand, is a lossless image format, ...
14
You think XNA has a lot of surface formats? Boy, you ain't seen nothing yet.
Joking aside, I suspect the reason has to do with a combination of legacy/backwards compatibility and flexibility.
Obviously, once a surface format is introduced it needs to be supported forward for some time, or the entire API takes a backwards compatibility hit. So there are ...
12
Just a couple of things to add to @Marco's answer:
.gif is sorely outdated. I would completely avoid using .gif files as much as possible. I think people only use them these days because of in-browser animations, and animated png's aren't well supported at this time.
So all you have is jpg and png.
PNG: Is lossless. The only thing you are considering ...
9
I doubt such a power tool exists, game companies create in house tools, max-scripts and Photoshop scripts to make up for the lack thereof.
They generally adapt because Photoshop is the tool that all artists need to know how to use. Even if you created a tool with all the functionality of Photoshop, artists would still prefer the original and even if you ...
8
The commonly used formats are PNG and PVR.
The PNG (Portable Network Graphics) format is compressed but lossless. It's a commonly used format (basically any image-editing software can write to PNG).
The PVR (PowerVR) format is a format that is much closer to the native memory structure of images on the GPU of the iPhone. Therefore it also allows for some ...
7
Some color data will be lost or changed regardless of your texture format. However, a bigger problem will be gamma correction. Gamma correction can be a tricky subject since your game will not appear visually the same across all display technologies and finding a single solution is not going to be easy.
These might help you out:
...
7
The image format is only a way to save raw data of pixels, so as long as you use bitmaps, the format usually does not make a difference in execution after the loading step. What matters is the pixel data supplied to the graphics API. There are three formats commonly used in the web:
.gif The (now normally deprecated) GIF format is used for images with 256 ...
7
For best quality results, you should probably first render the SVG at high resolution and then scale it down, using a good scaling algorithm. For example, here's the result I got by taking your 256 × 357 px image and scaling it down to 71 × 99 pixels in GIMP using Lanczos3 resampling:
It looks noticably sharper than the version you got using ...
5
How are you saving these PNG files from Fireworks? Fireworks uses PNG as its native file format, but adds meta-data to it (such as information about layers, effects etc.). This could be the reason why the Fireworks PNG files are larger than a PNG saved using Photoshop.
Since your iPhone app won't need any of the meta-information Fireworks stores, you should ...
5
Linear mapping is probably not the best solution (which I believe involves converting your RGB to a CIE colorspace, scaling there, and converting back), but it is very easy to implement, and the range difference is small enough it probably won't matter.
If you use SOIL, it can automatically do this when loading the image, by passing SOIL_FLAG_NTSC_SAFE_RGB ...
5
Since "2D Programming" is really now just 3D Programming, but with an orthographic viewpoint, what you need to look for is how to draw 2D things in 3D, using OpenGL.
When I did this I found the websites out there were often incomplete, too old or were written for the "wrong" OpenGL.
And that's what you need to choose first - do you want to write things on ...
5
Not really, no.
There's one scenario: you're calling the draw method so often you don't leave yourself the resources to do anything else. That's not your FPS negatively affecting how the game runs, though. The cause would be a badly written game, engine or framework; the FPS would just be a side-effect.
You have a glitch that surfaces on your desktop. Your ...
5
The parallelogram coordinates you're using are easier to work with, but they do have the drawback of being weird for rectangular maps. One approach is to store it with the offset coordinates but actually use parallelogram coordinates in your game logic.
Observation: in each row of the map, the grid data is contiguous. All the wasted space is on the left ...
4
You need a bigger image, or a (slightly) smaller ball.
It is a known issue that raster image algorithms tend to create ugly aliases on round(ish) objects, if they touch the 'edges'.
The easiest fix is adding a small 'background space' to all your balls. So for each of your generated tiles, instead of this:
+-----+
|.000.|
|00000|
|00000|
|00000|
|.000.|
...
4
sRGB is the default color space for most of todays operating systems. From Wikipedias entry about sRGB:
... one can generally assume, in the absence of embedded profiles or
any other information, that any 8-bit-per-channel image file or any
8-bit-per-channel image API or device interface can be treated as
being in the sRGB color space.
What that ...
4
I'm looking for good algorithms for compressing textures offline
What is your purpose in compressing these images? There are generally two reasons to compress a texture:
You want to make the texture smaller so that it takes up less memory on the GPU.
You want to make the texture smaller so that it takes less time to load/requires less harddrive space, ...
4
At the request of commenters...
Warning to Pyglet professionals: There may be a nice Pyglet way to do this, and this isn't it. It's a nice OpenGL way. You have been warned!
You can do this in OpenGL by first binding the texture, then calling glTexParameteri or similar varients. You can do this in Pyglet by importing OpenGL:
from pyglet.gl import *
You ...
4
Edit: Just saw that my answer was based on your code but didn't actually answer your question. I kept the old answer in case you can use that information.
Edit 2:
I have fixed 2 issues with the original code:
- The +1 addition in the calculation of end x and y was by mistake inside the brackets, but it needs to be added after the division.
- I forgot to ...
4
I can't help you with OpenGL, as I have never used it, but blobs of image data are usually just byte arrays, that are created row-wise from top to bottom. If you lock textures or images, the returned array might be bigger as expected because rows are usually stored aligned which is called the image stride. Those are effectively wasted bytes at the end of ...
4
Personally, I would prefer simplicity over saving memory. Don't optimize until needed!
If you're still bent on saving a few bytes, here's how you can do it:
Slice the parallelogram in half to form two right triangles
Rearrange the two triangles to form a rectangle.
(Note I added the green buffer strip so the math works out nicely.)
Python code to map ...
4
For fast software rendering, there are a few things you really want:
16-pixel scanline alignment, for SIMD or vectorized code.
32-bit RGBA or BGRA chunky (as opposed to planar) pixel formats, for fast 4-byte indexing. BGRA for fast copying to video memory for display, or RGBA because that's how image data is usually stored in files. If no alpha is needed, ...
4
Don't load them all into memory at once, that's just a terrible idea. Load them in from the hard drive when they come into play (on another thread), unload them when they're removed from play.
If you've got a deck in-game, pre-load the next few cards to prevent the game from freezing up when you draw a card.
4
Just fake the wrapping (I assume we're talking about working in Photoshop/Gimp and not doing it at runtime in a game):
Depending on your editor there might be an easier way to do this.
Double the size of the canvas while keeping the original image in the center (i.e. don't scale it).
Copy/tile the actual texture to fill the (still blank) space outside the ...
3
One possibility is ImageMagick, a set of command-line tools for doing things with images. You can write a script in your language of choice that calls the command-line tools to do whatever you need.
Another possibility is Python paired with PIL (Python Imaging Library), which lets you load image files as Python objects, programmatically perform operations ...
3
Mesh material settings are dependent on the game and engine(s) used, which is why there are no specific tools that let you load up any kind of mesh file and take the referenced data from it.
Such a tool will have to cover a broad area of material formats, or expect custom ones. If you are working with OBJ files, for example, the editor will have to be able ...
3
If you want your images to look good, do not simply scale up/down a raster image.
Even with a vector based source, this doesn't always work so well, though the results are usually passable.
The best example of this I can give is this: say you wanted to resize this 48x48 icon into a 24x24 alternative. In 24 pixels, you likely would want to reduce the ...
3
If you add a PNG image in the Flash IDE, you can choose JPEG compression for it. The interesting part about this is, that it will preserve alpha transparency.
So what internally happens is exactly as you describe. The alpha channel and the color information get separated and compressed individually. AFAIK the alpha will always be JPEG compressed whereas I'm ...
Only top voted, non community-wiki answers of a minimum length are eligible

