Beispiel #1
0
        public SdlSurface(IntPtr ptr)
        {
            _ptr = ptr;

            Flags     = unchecked ((uint)Marshal.ReadInt32(ptr, FLAGS_OFFSET));
            FormatPtr = Marshal.ReadIntPtr(ptr, FORMAT_OFFSET);
            Width     = Marshal.ReadInt32(ptr, WIDTH_OFFSET);
            Height    = Marshal.ReadInt32(ptr, HEIGHT_OFFSET);
            Pitch     = Marshal.ReadInt32(ptr, PITCH_OFFSET);
            Pixels    = Marshal.ReadIntPtr(ptr, PIXELS_OFFSET);

            Format = Marshal.PtrToStructure <SDL_PixelFormat>(FormatPtr);
        }
Beispiel #2
0
 private void FromSDL(SDL_PixelFormat fmt)
 {
     if (fmt.palette != IntPtr.Zero)
     {
         _palette = new Palette(fmt.palette);
     }
     Format        = (PixelFormat)fmt.format;
     BitsPerPixel  = Format.GetBitsPerPixel();
     BytesPerPixel = Format.GetBytesPerPixel();
     unchecked
     {
         MaskR = (int)fmt.Rmask;
         MaskG = (int)fmt.Gmask;
         MaskB = (int)fmt.Bmask;
         MaskA = (int)fmt.Amask;
     }
 }
        void IGraphicsDriver.SetPalette(GraphicsColor[] colors)
        {
            //for (int i = 0; i < colors.Length; i++)
            //{
            //    this.palette[i] = (uint)(((byte)0xff << 24) | (colors[i].R << 16) | (colors[i].G << 8) | colors[i].B);
            //}
            SDL_Color[] palette = new SDL_Color[colors.Length];
            for (int i = 0; i < colors.Length; i++)
            {
                palette[i].r = colors[i].R;
                palette[i].g = colors[i].G;
                palette[i].b = colors[i].B;
                //palette[i].unused = 0;
            }

            SDL_Surface     surface = (SDL_Surface)Marshal.PtrToStructure(this.surfacePtr, typeof(SDL_Surface));
            SDL_PixelFormat format  = (SDL_PixelFormat)Marshal.PtrToStructure(surface.format, typeof(SDL_PixelFormat));

            SDL_SetPaletteColors(format.palette, palette, 0, palette.Length);

            this.texturePtr = SDL_CreateTextureFromSurface(this.rendererPtr, this.surfacePtr);
        }
Beispiel #4
0
 public static unsafe SDL_Surface SDL_CreateRGBSurfaceWithFormat(uint flags, int width, int height, int depth, SDL_PixelFormat format) => CreateRGBSurfaceWithFormatImpl(flags, width, height, depth, format);
Beispiel #5
0
 public static unsafe SDL_Surface SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int width, int height, int depth, int pitch, SDL_PixelFormat format) => CreateRGBSurfaceWithFormatFromImpl(pixels, width, height, depth, pitch, format);
 static extern uint SDL_MapRGBA(SDL_PixelFormat* fmt, byte r, byte g, byte b, byte a);
 static extern SDL_Surface* SDL_ConvertSurface(SDL_Surface* src, SDL_PixelFormat* fmt, int flags);