add stride info
parent
28afef0324
commit
3249b05ae4
7
xormod.c
7
xormod.c
|
@ -18,6 +18,7 @@ typedef struct {
|
|||
int y2;
|
||||
int w;
|
||||
int h;
|
||||
int s;
|
||||
SDL_Surface *surface;
|
||||
SDL_Texture *texture;
|
||||
uint32_t *pixels;
|
||||
|
@ -37,11 +38,11 @@ static Picture *Picture_new(SDL_Renderer *rend,
|
|||
p->w = w;
|
||||
p->h = h;
|
||||
p->color = color;
|
||||
p->s = (w + 7) / 8 * 8;
|
||||
|
||||
int stride = (w + 7) / 8 * 8;
|
||||
p->pixels = malloc(stride * h * sizeof(uint32_t));
|
||||
p->pixels = malloc(p->s * h * sizeof(uint32_t));
|
||||
p->surface = SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
p->pixels, w, h, 32, stride * sizeof(uint32_t),
|
||||
p->pixels, w, h, 32, p->s * sizeof(uint32_t),
|
||||
SDL_PIXELFORMAT_RGBA32);
|
||||
|
||||
Picture_render(p, rend);
|
||||
|
|
Loading…
Reference in New Issue