Re: [Vala] Dereferencing a pointer



                /**
                 * Sets a pixel to a given color
                 * @param p The position of the desired pixel
                 * @param color The color to use
                 */
                [CCode(array_length=false)]
                public void setPixel(Point p, Color color) {
                        uint32 pixel = surface.format.map_rgba(color.red, color.green,
                                color.blue, color.alpha);

                        switch(surface.format.BytesPerPixel) {
                                case 4:
                                        weak uint32[] blah = ((uint32[])surface.pixels);
                                        blah[(p.y * surface.w) + p.x] = pixel;
                                        break;
                                case 2:
                                        weak uint16[] blah = ((uint16[])surface.pixels);
                                        blah[(p.y * surface.w) + p.x] = (uint16)pixel;
                                        break;
                                case 1:
                                        weak uchar[] blah = ((uchar[])surface.pixels);
                                        blah[(p.y * surface.w) + p.x] = (uchar)pixel;
                                        break;
                        }// switch on pixel size
                }// setPixel



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]