gdk pixmap vs gdk pixbuf
글쓴이: seongwon1 / 작성시간: 화, 2007/05/08 - 9:45오전
안녕하세요?
gdk를 보면 그림(넓게 잡아서)을 그리는데, gdk pixmap과 gdk pixbuf 라는 두 가지 개념을 사용합니다.
그냥 대충 API를 이용해서 프로그램을 만드는건 별 문제가 없습니다만,
두 개념의 차이가 궁금합니다. gdk 소소를 봐도, 어렴풋이 이런건가??? 하고 추측만 가능할 뿐이어서...
pixmap 같은 경우, gdk 에서 뿐만 아니라 그래픽 쪽에 넓게 쓰이는 개념 같던데,
pixbuf는 구글링을 해봐도 개념에 대해선 잘 검색이 안되더군요.
pixmap과 pixbuf의 차이점 좀 가르쳐 주세요.
감사합니다.
Forums:
pixmap (x server), pixbuf (x client)
웹에서 찾아본 결과 window X system에서 디스플레이하는 방식의 차이 같네요.
http://mail.gnome.org/archives/gtk-perl-list/2006-March/msg00036.html
...
The X Window System uses a client/server architecture in which the screen and windows on it are managed by a window server, which deals with the display and input hardware. This server provides windowing services to client applications. (Many people think X's client and server names are backwards, but when seen from the point of view that the server provides windowing services to client applications, it makes sense.)
The client and server are not only separate processes, but may be on different physical machines. Because of this, the latency for a round trip to the server can be quite large, and the X model for many operations is designed to minimize this. That's where graphics contexts and pixmaps come from. A graphics context ("GC") is a server-side resource that contains information on how to perform drawing operations. The client has a handle which refers to a particular GC, and passes the handle with drawing operations. This keeps the client from having to transmit all of that information with each drawing command.
Similarly, image data can be stored in "bitmaps" (1-bit images, or maps of bits) or "pixmaps" (maps of more-than-one-bit pixels, or pixel maps). These are stored on the server, at device bit resolution and bit depth, and this can be manipulated quite quickly. Operations like $drawable->draw_pixmap() involve copying only the command information from the client to the server, because all of the bits are already on the server. These are stored in the server's memory.
So where does a GdkPixbuf fit in? Recall that the pixmap is stored on the server at device resolution and bitdepth. This means that if you want to change just one pixel, you have to do a round trip, which is expensive. Also, you'll have to deal with the image data at the server's bit depth, which could be anything -- 888, 565, indexed pseudocolor, etc, maybe involving dithering. Because this is a royal PITA, the gnome guys came up with GdkPixbuf, which is a simple 24-bit RGB or 32-bit RGBA image buffer stored in the *client*, which can be dithered and transferred to the server as needed. (The RENDER extension includes features to make this more efficient.)
GtkImage provides a way for you to set the source data directly from a pixbuf --- $image->set_from_pixbuf($pixbuf) --- so you could avoid the pixmap/mask stage.
You can also place a GdkPixbuf into a GnomeCanvas, which gives you more efficient rendering of the changed portions. You could use GnomeCanvasItems for the selected objects text overlays and that sort of stuff, along with scaling and other fun tricks.
You'll probably want also check for reference leaks in your code to make sure you're not piling up pixbufs.
If using a Canvas is not practical, you can probably drop a few steps by writing some of the more compute-intensive display stuff in C --- if you already have custom C code, then binding your own C widgets to gtk2-perl should be no problem. You could do stuff like render much smaller pieces from the source data and blit them exactly where they need to go in the master pixbuf.
...
GtkImage, GdkPixbuf, GdkPixmap GdkDrawable 차이점
추가합니다.
[pygtk] Difference between image format
http://www.daa.com.au/pipermail/pygtk/2004-April/007478.html
GtkImage -> gtk widget that draws an image
GtkPixbuf -> doesn't exist, it is called GdkPixbuf, which is a client-side object that holds an image
GtkPixmap -> GdkPixmap -> an X server object that contains an image
GtkDrawable -> GdkDrawable -> any X server object you can draw to, i.e. a GdkWindow or a GdkPixmap.
Re: Image process in gdk
http://www.mail-archive.com/gtk-app-devel-list@gnome.org/msg08976.html
> > GdkPixbuf -- RGB[A] pixel buffer, used for basic image data representation and manipulation.
> > GdkPixmap -- off-screen drawable, i.e. off-screen relative of GdkWindow (both are GdkDrawables).
> > GtkPixbuf -- does not exist.
> > GtkPixmap -- deprecated widget, use GtkImage instead.
댓글 달기