What's required to show jpg in shared memory

Pekka Paalanen ppaalanen at gmail.com
Wed Feb 25 00:16:46 PST 2015


On Wed, 25 Feb 2015 07:47:30 +0000
Michael Johnson <mikeyj001 at hotmail.com> wrote:

> -Hi all,
> 
> I just need a little help.  I created a little program loosely based on the "Hello Wayland" tutorial.  In tutorial they use a file called images.bin, and state:
> 
> " This image file contains the hardcoded images for the hello world application, already in a raw format for display: it’s the pixel values for the main window, followed by the pixel values for the cursor."
> 
> So I've tried using my test image file in bmp, png, raw and jpg formats, but with little success of showing the image properly.  The jpg doesn't show at all, while the other three showed a portion of the image around 3 times (side by side) within the given dimensions of 800x600, which is the size of the test image.  All crash the program with a message like "unable to access SHM".
> 
> My question is, what format should the image be converted to in order for it to be shown properly in shared memory?

Images in memory are usually in raw format. This is not .raw file
format or any file format, it is just the actual pixel values, pixel by
pixel, row by row, in memory.

What a pixel is, is defined by the pixel format. It is very common to
have 4 bytes per pixel, where each byte is a red, green, blue, or alpha
component.

This all is really the fundamental basics of digital images, so you
should probably find some introductory course or book on digital
images, computer graphics or something like that.

If you want to show an image in a program, you usually use a library
that can decode the image file into raw bytes in memory. wl_shm
interface specifies how to arrange those raw bytes, but it assumes you
know the basic concepts like pixel format, width, height, stride or
pitch, and bytes.

You could look into the simple-shm.c demo in Weston. It uses equations
to create a colorful pattern in memory, instead of loading an image
from a file.


Thanks,
pq


More information about the wayland-devel mailing list