本文整理汇总了C++中PixelBuffer::getPixelAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ PixelBuffer::getPixelAddr方法的具体用法?C++ PixelBuffer::getPixelAddr怎么用?C++ PixelBuffer::getPixelAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PixelBuffer
的用法示例。
在下文中一共展示了PixelBuffer::getPixelAddr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PixelBuffer
Texture *NGE_SDL_Texture_Load(const char *path)
{
PixelBuffer *buf;
Texture *tex = NULL;
SDL_Surface *surface;
Sint32 i, j;
Uint8 *p, *q;
Uint8 r, g, b, a;
if(path) {
if((surface = IMG_Load(path))) {
//SDL_LockSurface(surface); -> peut poser des pb
buf = new PixelBuffer(surface->format->BytesPerPixel, surface->w, surface->h);
p = (Uint8 *) surface->pixels;
//for(i = 0; i < surface->h; i++) {
for(i = surface->h - 1; i >= 0; i--) {
q = buf->getPixelAddr(0, i);
for(j = 0; j < surface->w; j++) {
r = p[j * surface->format->BytesPerPixel + 0];
g = p[j * surface->format->BytesPerPixel + 1];
b = p[j * surface->format->BytesPerPixel + 2];
if(surface->format->BytesPerPixel == 4)
a = p[j * surface->format->BytesPerPixel + 3];
else;
q[j * surface->format->BytesPerPixel + 0] = r;
q[j * surface->format->BytesPerPixel + 1] = g;
q[j * surface->format->BytesPerPixel + 2] = b;
if(surface->format->BytesPerPixel == 4)
q[j * surface->format->BytesPerPixel + 3] = a;
else;
}
//p += surface->format->BytesPerPixel * surface->w;
p += surface->format->BytesPerPixel * surface->w;
}
tex = new Texture();
tex->setPixelBuffer(buf);
// tex->updateInGC();
//SDL_UnlockSurface(surface);
SDL_FreeSurface(surface);
}
else
printf("Texture \"%s\" not loaded: not found.\n", path);
}
else;
return tex;
}