PicoGUI's pgNewBitmap function can handle this. It supports the PPM format,
which is just 24-bit RGB data with a small header. Here's an example of
generating an RGB bitmap at runtime:
------8<------
/* Demonstration of loading RGB pixel values as a bitmap in PicoGUI */
#include <picogui.h>
#include <malloc.h>
/* Build a 24-bit PPM file with a 2D gradient */
pghandle gradient_bitmap(void) {
char *pnmfile,*bitdata,*p;
int w,h,x,y;
long size;
/* Allocate memory to construct our bitmap in */
w = 255;
h = 255;
size = w * h * 3 + 20; /* 20 is space for our header */
pnmfile = malloc(w * h * 3 + 20);
/* Write the header for a binary 24-bit PPM file */
bitdata = pnmfile + sprintf(pnmfile,"P6 %d %d 255\n",w,h);
/* Draw some colors in our bitmap */
p = bitdata;
for (y=0;y<h;y++)
for (x=0;x<w;x++) {
*(p++) = 0; /* Red */
*(p++) = x; /* Green */
*(p++) = y; /* Blue */
}
/* Allocate a picogui bitmap, freeing our buffer */
return pgNewBitmap(pgFromTempMemory(pnmfile,size));
}
/* Make an app to show our bitmap in */
int main(int argc, char **argv) {
pgInit(argc,argv);
pgRegisterApp(PG_APP_NORMAL,"RGB Bitmap Test",0);
pgNewWidget(PG_WIDGET_BITMAP,0,0);
pgSetWidget(PGDEFAULT,
PG_WP_SIDE,PG_S_ALL,
PG_WP_BITMAP,gradient_bitmap(),
0);
pgEventLoop();
return 0;
}
------>8------
Also: In Waba, isn't this function mainly used for loading BMP format data?
PicoGUI is now capable of loading BMP data in pgNewBitmap(), so you should be
able to bypass Waba's built-in BMP decoder and just send the BMP file itself to
pgNewBitmap().
Quoting Olivier Bornet <[EMAIL PROTECTED]>:
> Hello,
>
> I want to display a RGB buffer I have in memory (let's call it
> rgbbuf).
> The buffer consist of an array of the red, green and blue values of
> each
> pixel (red1, green1, blue1, red2, green2, blue2, red3, green3, blue3,
> ...). No separation are made for lines break. I just know the width
> (w)
> and height (h) of the bitmap.
>
> I can do it with something like :
>
> pos = rgbbuf;
> for( myY = 0; myY < h; myY++ ) {
> for( myX = 0; myX < w; myX++ ) {
>
> myColor = ((pgcolor *)pos)[ 0 ];
> pos += 3;
>
> pgSetColor( gc, myColor );
> pgPixel( gc, x + myX, y + myY );
>
> }
> }
>
> But this is slow. The slowing part is to make every time the
> pgSetColor() and pgPixel(). I have try to go trough a bitmap in
> memory,
> but without significant improvement.
>
> In gtk, we have the function gdk_draw_rgb_image() for this.
>
> Thanks in advance.
>
> Olivier
> --
> Olivier Bornet SMARTDATA SA
> [EMAIL PROTECTED] Centre du Parc
> http://www.smartdata.ch av. des Pr�s-Beudin 20
> Phone +41-27-723'55'03 1920 Martigny
> Fax +41-27-723'55'19 Phone +41-27-723'55'18
>
> _______________________________________________
> Pgui-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/pgui-devel
>
--
Only you can prevent creeping featurism!
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel