What image format can fast load C #?

this may seem like a strange question, and I don’t know the image formats, so I’ll just go and ask ...

I make a minesweeper game (which also applies to different things), which uses a grid of buttons, and then add a sprite to the buttons using backgroundImage . If the grid is 9x9, then this is normal. 15x15 slows down, and 30x30 you can see every downloadable button.

This brings me to my question: which image format will load the fastest? Obviously, the file size takes part in the download speed, however I ask the question whether, say, jpeg - with the same file size as gif - will load faster. or bmp, png, etc.

I ask for this to find out if I can load my grid faster using a different format.

Thanks!

+6
source share
4 answers

You want the image format to color faster. There is only one, one whose pixel format directly matches the video adapter setting, so that pixel data can be copied directly without the need for format settings.

On most modern machines, this PixelFormat.Format32bppPArgb. He draws ten times faster than everyone else.

You will not get this format when downloading an image from a resource or file, you must create it .

Please note that this still will not give you the speed of star paint if each cell in the grid is a control. In particular, if it is a button, they are very expensive to attract, since they support transparency effects. You will only advance here if you draw the entire grid in one Paint event handler. Like a form.

A completely different approach is to hide the visible delays of this hack .

+8
source

use the 8-bit PNG or GIF format and reduce the number of colors in the palette. Some graphics programs, such as PhotoShop, allow you to save an image on the Internet and fine tune image settings. Reducing the color palette from 256 to about 32, you significantly reduce the file size. The fewer colors than the image, the smaller the file size.

PNG has a similar function called "interlacing." You can disable this feature to speed up the loading of the full image.

Since 8-bit PNG and GIF formats can lead to significantly smaller image files, try to take this into account when creating graphics and illustrations for your application. Try to keep the number of colors to a minimum and use flat graphics instead of photos. This way you can create images with palettes of 16 colors, keeping the file size very small and fast to load.

Best wishes

+2
source

Do you reload the image every time you draw a button? If so, then your problem is to solve it using the cache.

Do you draw an image to your native size? Re-fetching runtimes can lead to better performance.

+1
source

use PNG or GIF faster image types

0
source

All Articles