Re: drawing a generated bitmap

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

 



hi,

i do something like this in an application to draw probability  
density function plots.  what i do is render the image to an internal  
RGB buffer, followed by gdk_draw_rgb_image() to render it to the  
internal pixmap (this pixmap subsequently rendered to the screen):

width = DrawingArea->allocation.width;
height = DrawingArea->allocation.height;
rgbbuf = malloc(width * height * 3);
memset(rgbbuf, 240, width * height * 3);		// set the background to  
GREY=(240, 240, 240)
DrawBufferImage(rgbbuf, width, height, data);
gdk_draw_rgb_image(pixmap, DrawingArea->style->fg_gc[GTK_STATE_NORMAL],
	0, 0, width, height, GDK_RGB_DITHER_NONE, rgbbuf, width*3);
free(rgbbuf);

inside the DrawBufferImage() routine, i examine the data, point by  
point, and assign each pixel to be the RGB combination corresponding  
to the colour defined/assigned for each data value.

my input data also dictates an absolute starting size, so inside the  
DrawBufferImage() routine, i also magnify the image using a bi-cubic  
spline interpolation algorithm.  the speed achieved in ultimately  
rendering the image is as fast as possible, and there is no real  
discernable delay between receiving the data to plot and rendering  
the image to the screen, i.e., it's instantaneous.

plotting pixel by pixel (and magnifying to boot) can result in a  
quickly drawn image (depending on the number of data points, of  
course), if gone about in the right manner.

cheers,

richard


On Jun 18, 2006, at 1:28 PM, kamil stachowski wrote:

> thank you for the answer :)
>
>> Don't draw pixel by pixel, it would be awfully slow.
>> Use GdkPixbufs and gdk_draw_pixbuf().
>
> you mean "don't draw pixel by pixel using drawpoint", is that it?
>
>> Something along these lines should be doable *if* you can
>> get a indexed color visual, which you cannot count on.  So
>> I would just redraw it (incidentally I develop a program
>> which uses false-color maps a lot and redrawing works good
>> enough).
>
> that's a pity but i'll have to cope with that if there's no other way.
>
> however, i ran into a problem with colourmaps. i was using  
> gdk.image (has the
> putpixel method which treats the colours in a more traditional way,  
> and seems
> to be fast enough for my needs) but didn't manage to change the  
> colours it
> uses. i keep getting a blue gradient which is not precisely what i  
> want.
> here's the code:
>
> def img=Image(ImageType.Fastest,Visual.System,500,500);
> for (mutable x=0, x<500; x++) for (mutable y=0; y<500; y++)
> 	img.PutPixel(x,y,(x+y):>UInt32);
> 		
> def gc=GC(args.Event.Window);
> mutable col=Color(0xff,0,0);
> gc.Colormap.AllocColor(ref col,true,true);
> img.Colormap=gc.Colormap;
>
> args.Event.Window.DrawImage(gc,img,0,0,0,0,500,500);
>
> i don't seem to be able to spot anything red in the result. could  
> you please
> tell me what i am doing wrong?
> _______________________________________________
> 
> gtk-list@xxxxxxxxx
> http://mail.gnome.org/mailman/listinfo/gtk-list
>

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux