gdk pixmap vs gdk pixbuf

seongwon1의 이미지

안녕하세요?

gdk를 보면 그림(넓게 잡아서)을 그리는데, gdk pixmap과 gdk pixbuf 라는 두 가지 개념을 사용합니다.

그냥 대충 API를 이용해서 프로그램을 만드는건 별 문제가 없습니다만,

두 개념의 차이가 궁금합니다. gdk 소소를 봐도, 어렴풋이 이런건가??? 하고 추측만 가능할 뿐이어서...

pixmap 같은 경우, gdk 에서 뿐만 아니라 그래픽 쪽에 넓게 쓰이는 개념 같던데,

pixbuf는 구글링을 해봐도 개념에 대해선 잘 검색이 안되더군요.

pixmap과 pixbuf의 차이점 좀 가르쳐 주세요.

감사합니다.

l22bss의 이미지

웹에서 찾아본 결과 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.

...

l22bss의 이미지

추가합니다.

[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.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.