Hi, I've recently run into a roadblock on a project I was working on and was wondering if anyone here has some good advice. I've got a big pixmap that I need to draw many characters to(lets say 1000 characters). Each character must be positioned at a particular points so I can't just put it into one big Pango layout(which is nice and fast). I'm currently rendering many single character pango layouts to the pixmap, but it takes a very long time. I was going to try to use the draw_text method, but it doesn't seem to have been implemented. What is the best/fastest way of drawing a bunch of arbitrarily positioned characters on a pixbuf? Any ideas? Conan K Woods ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
on 2007-01-02 20:29
on 2007-01-03 03:45
Hey Conan, Couple of questions here, with a couple of solutions included. First, are any of the letters going to be positioned next to each other, or are they just going to be flinged where ever? If they are going to be positioned next to each other, then you can group together thoes letters, and draw them, that way, there is less repititon. Secondly, are they going to all be the same color, size, and font, or are there going to be different fonts, different colors, or different sizes? If they are going to all be the same color, size, and font, then what I suggest, is instead of drawing out each letter, Create 26 or 52 Pixbufs of Single Characters (26 for all Capital Letters, or 52 For both Capital and Lower Case letters), then, just use thoes to blit/draw onto the Pango Buffer. Drawing/Blitting Pixbuf to Pixbuf is 90 percent faster then using Text Font Drawing, though there is more memory usage. Thoes are the options that I suggest myself. Conan K Woods wrote: > What is the best/fastest way of drawing a bunch of arbitrarily > _______________________________________________ > ruby-gnome2-devel-en mailing list > ruby-gnome2-devel-en@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-e ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
on 2007-01-03 06:41
Whoops, made a typo on my stuff. I've been using Pixmaps(as a drawable), not a pixbuf I believe. Maybe a Pixbuf is a better idea? But what you said makes sense, and I'd like to draw pixmap to pixmap that way, but unfortunately the characters quite often need to overlap, so I would need to have some kind of alpha channel? I'm not sure if there is a way to do this with pixmaps. Memory usage isn't a big deal for what I am doing at the moment, but I do need a faster way of drawing the characters. So.... If a Pixbuf is more appropriate, and does alpha layers, how would I get a pango character rendered as a pixbuf with a alpha layer so that I could render it to my drawable? Memory usage is no object ;-) Hopefully that all makes sense Conan K Woods Mario Steele wrote: > > Thoes are the options that I suggest myself. >> the draw_text method, but it doesn't seem to have been implemented. >> opinions on IT & business topics through brief surveys - and earn cash > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ruby-gnome2-devel-en mailing list > ruby-gnome2-devel-en@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
on 2007-01-03 07:03
No problem, I can understand. Often times they are refered to Pixmaps, and Pixbufs both, but it means the same thing, a Offscreen Memory Device Independent Bitmap (DIB). You would still use the Pango Functions that you use now, to draw the characters, only instead of rendering to a Pango Context/Canvas, you would render to a Pixmap/Pixbuf/DIB to be used for later purposes. Alpha Channel would be best used for transparent blitting. Check the Ruby/Gnome2 Methods for Alpha Channel Blending, and Transparent Drawing. I know there are specific functions you can use, and you can select a Transparent Color to use to transparently draw with. I don't remember right off hand what methods you need to use to make it work, but I know it's there, just gotta look for it. LOL L8ers, Mario Steele
on 2007-01-03 18:33
On Mi, 2007-01-03 at 00:02 -0600, Mario Steele wrote: Hi, cause here are many terms mixed up i'll try to bring a little bit of clarification. A Pixmap is just the repesentation of some pixeldata. To use pixmaps for bliting they have to have the same color depth than the window they get copied on. Also you have to handle all the internals like colormaps, GC's and such yourself. If you are on this level you can also do the fontrendering in Gdk directly. That would be the fasted way. A Pixbuf has a little bit more of "intelligence". They are also bitmap representations but you don't have to care about colormaps and such. On the downside you can't draw (lines, circles,...) on pixbufs. So, what way to go? 1. Do it the fastest but also hardest way direct in Gdk. If you don`t know Gdk very well (and i think so, else you wouldn't ask here ;-) ) it will take you much time to learn. Buy the X-Windows Reference Manual and the X-Windows Programming Manual and take a longer holiday ;-) 2. You can render your characters with pango onto a Pixmap. Get the data from the pixmap and add the transparency by hand bit for bit. Then generate a Pixbuf from this data. With this pixbuf you can render to an other pixmap, which you then can put into a Gtk::Image. With this two aproches you have much problems with non-western languages. 3. Optimize your code. The pango renderer is very fast today. I.e. only render the text that has changed. With every expose event you get the rectangle of the area that has changed. If text moves also move it with the drawing functions and don't render it again. To give better hints i need a better description what you exactly want to display. 4. buy a faster computer ;-) Cheers detlef > what methods you need to use to make it work, but I know it's there, > just gotta look for it. LOL ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
on 2007-01-03 20:18
Ok, that makes sense. Option #2 seems best for me. (From my benchmarking the rest of my code is efficient enough, the slowness seems to be caused by calling Pixmap.draw_layout thousands of time. I actually render only once to a big pixmap and just bits of the pixmap which seems nice and fast. But the initial drawing of text takes close to a minute.) I'm not sure how to add the transparency bit by bit, like you said I'm far from a graphics expert. Is their a way to do this that: A) Wouldn't involve me saying "This pixel is transparent, this pixel is transparent, this pixel is kinda transparent, this pixel ain't transparent". B) Work with the antialiased fonts(If not, I can always just use non antialiased fonts). Conan K Woods Detlef Reichl wrote: > GC's and such yourself. If you are on this level you can also do the > the X-Windows Programming Manual and take a longer holiday ;-) > 3. Optimize your code. The pango renderer is very fast today. I.e. only > >> to use to transparently draw with. I don't remember right off hand > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ruby-gnome2-devel-en mailing list > ruby-gnome2-devel-en@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en > ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
on 2007-01-03 20:58
On Mi, 2007-01-03 at 11:16 -0800, Conan K Woods wrote: > Ok, that makes sense. Option #2 seems best for me. (From my > benchmarking the rest of my code is efficient enough, the slowness seems > to be caused by calling Pixmap.draw_layout thousands of time. I > actually render only once to a big pixmap and just bits of the pixmap > which seems nice and fast. But the initial drawing of text takes close > to a minute.) Are all the thousands of characters are visible at once? Else render only the visible ones first and the others only on expose or in a timeout handler in the background. > > I'm not sure how to add the transparency bit by bit, like you said I'm > far from a graphics expert. Is their a way to do this that: > > A) Wouldn't involve me saying "This pixel is transparent, this pixel is > transparent, this pixel is kinda transparent, this pixel ain't > transparent". > B) Work with the antialiased fonts(If not, I can always just use non > antialiased fonts). > If you want antialiased fonts you have to look at every pixel yourself, cause Pixmaps don't know transparency. Else you can use Gdk::Pixbuf#render_pixmap_and_mask which will also generates the cliping mask. An other option, that i forgot is to use OpenGL. I don't know if it is an option for your project, but todays graphics cards shouldn't have a problem with so many objects. > > clarification. > > > > other pixmap, which you then can put into a Gtk::Image. > > 4. buy a faster computer ;-) > >> rendering to a Pango Context/Canvas, you would render to a > > > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > ruby-gnome2-devel-en mailing list > ruby-gnome2-devel-en@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/ruby-gnome2-devel-en ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.