Branch: Tag:

2005-07-28

2005-07-28 15:26:09 by Martin Nilsson <mani@lysator.liu.se>

GTK2

Rev: src/post_modules/GTK2/AUTHORS:1.1
Rev: src/post_modules/GTK2/build_pgtk.pike:1.1
Rev: src/post_modules/GTK2/gdkeventstrings.h:1.1
Rev: src/post_modules/GTK2/module.pmod.in:1.1
Rev: src/post_modules/GTK2/pgtk.h:1.1
Rev: src/post_modules/GTK2/source/common_draw.inc:1.1
Rev: src/post_modules/GTK2/source/constants.pre:1.1
Rev: src/post_modules/GTK2/source/encode_truecolor.c:1.1
Rev: src/post_modules/GTK2/source/gdkatom.pre:1.1
Rev: src/post_modules/GTK2/source/gdkbitmap.pre:1.1
Rev: src/post_modules/GTK2/source/gdkcolor.pre:1.1
Rev: src/post_modules/GTK2/source/gdkdisplay.pre:1.1
Rev: src/post_modules/GTK2/source/gdkdragcontext.pre:1.1
Rev: src/post_modules/GTK2/source/gdkdrawable.pre:1.1
Rev: src/post_modules/GTK2/source/gdkevent.pre:1.1
Rev: src/post_modules/GTK2/source/gdkgc.pre:1.1
Rev: src/post_modules/GTK2/source/gdkimage.pre:1.1
Rev: src/post_modules/GTK2/source/gdkpixbuf.pre:1.1
Rev: src/post_modules/GTK2/source/gdkpixbufanimation.pre:1.1
Rev: src/post_modules/GTK2/source/gdkpixbufanimationiter.pre:1.1
Rev: src/post_modules/GTK2/source/gdkpixmap.pre:1.1
Rev: src/post_modules/GTK2/source/gdkrectangle.pre:1.1
Rev: src/post_modules/GTK2/source/gdkregion.pre:1.1
Rev: src/post_modules/GTK2/source/gdkwindow.pre:1.1
Rev: src/post_modules/GTK2/source/gladexml.pre:1.1
Rev: src/post_modules/GTK2/source/global.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeabout.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeapp.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeappbar.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeapplet.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecalculator.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecanvas.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecanvasgroup.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecanvasitem.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecanvasline.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomecolorpicker.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedateedit.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedialog.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedock.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedockband.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedockitem.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedocklayout.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedruid.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedruidpage.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedruidpagefinish.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedruidpagestandard.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomedruidpagestart.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomehref.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeiconentry.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeiconselection.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomeless.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomemessagebox.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomenumberentry.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomepaperselector.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomepropertybox.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomescores.pre:1.1
Rev: src/post_modules/GTK2/source/gnome/gnomestatusdocklet.pre:1.1
Rev: src/post_modules/GTK2/source/gnomeapp.pre:1.1
Rev: src/post_modules/GTK2/source/gnomeappbar.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvas.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasbpath.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasclipgroup.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasellipse.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasgroup.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasitem.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasline.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvaspixbuf.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasre.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasrect.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasrichtext.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvasshape.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvastext.pre:1.1
Rev: src/post_modules/GTK2/source/gnomecanvaswidget.pre:1.1
Rev: src/post_modules/GTK2/source/gnomeclient.pre:1.1
Rev: src/post_modules/GTK2/source/gnomedateedit.pre:1.1
Rev: src/post_modules/GTK2/source/gnomedruid.pre:1.1
Rev: src/post_modules/GTK2/source/gnomedruidpage.pre:1.1
Rev: src/post_modules/GTK2/source/gnomedruidpageedge.pre:1.1
Rev: src/post_modules/GTK2/source/gnomedruidpagestandard.pre:1.1
Rev: src/post_modules/GTK2/source/gnomehref.pre:1.1
Rev: src/post_modules/GTK2/source/gnomeiconentry.pre:1.1
Rev: src/post_modules/GTK2/source/gnomeiconselection.pre:1.1
Rev: src/post_modules/GTK2/source/gobject.pre:1.1
Rev: src/post_modules/GTK2/source/gtkaboutdialog.pre:1.1
Rev: src/post_modules/GTK2/source/gtkaccelgroup.pre:1.1
Rev: src/post_modules/GTK2/source/gtkaccellabel.pre:1.1
Rev: src/post_modules/GTK2/source/gtkaction.pre:1.1
Rev: src/post_modules/GTK2/source/gtkactiongroup.pre:1.1
Rev: src/post_modules/GTK2/source/gtkadjustment.pre:1.1
Rev: src/post_modules/GTK2/source/gtkalignment.pre:1.1
Rev: src/post_modules/GTK2/source/gtkarrow.pre:1.1
Rev: src/post_modules/GTK2/source/gtkaspectframe.pre:1.1
Rev: src/post_modules/GTK2/source/gtkbin.pre:1.1
Rev: src/post_modules/GTK2/source/gtkbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkbuttonbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcalendar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcelleditable.inc:1.1
Rev: src/post_modules/GTK2/source/gtkcelllayout.inc:1.1
Rev: src/post_modules/GTK2/source/gtkcellrenderer.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellrenderercombo.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellrendererpixbuf.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellrendererprogress.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellrenderertext.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellrenderertoggle.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcellview.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcheckbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcheckmenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtkclipboard.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcolorbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcolorselection.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcolorselectiondialog.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcombo.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcombobox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcomboboxentry.pre:1.1
Rev: src/post_modules/GTK2/source/gtkcontainer.pre:1.1
Rev: src/post_modules/GTK2/source/gtkdata.pre:1.1
Rev: src/post_modules/GTK2/source/gtkdialog.pre:1.1
Rev: src/post_modules/GTK2/source/gtkdrawingarea.pre:1.1
Rev: src/post_modules/GTK2/source/gtkeditable.inc:1.1
Rev: src/post_modules/GTK2/source/gtkentry.pre:1.1
Rev: src/post_modules/GTK2/source/gtkentrycompletion.pre:1.1
Rev: src/post_modules/GTK2/source/gtkeventbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkexpander.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfilechooser.inc:1.1
Rev: src/post_modules/GTK2/source/gtkfilechooserbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfilechooserdialog.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfilechooserwidget.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfilefilter.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfileselection.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfixed.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfontbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfontselection.pre:1.1
Rev: src/post_modules/GTK2/source/gtkfontselectiondialog.pre:1.1
Rev: src/post_modules/GTK2/source/gtkframe.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhandlebox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhbuttonbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhpaned.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhscale.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhscrollbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkhseparator.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconfactory.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconinfo.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconset.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconsize.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconsource.pre:1.1
Rev: src/post_modules/GTK2/source/gtkicontheme.pre:1.1
Rev: src/post_modules/GTK2/source/gtkiconview.pre:1.1
Rev: src/post_modules/GTK2/source/gtkimage.pre:1.1
Rev: src/post_modules/GTK2/source/gtkimagemenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtkinvisible.pre:1.1
Rev: src/post_modules/GTK2/source/gtkitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtklabel.pre:1.1
Rev: src/post_modules/GTK2/source/gtklayout.pre:1.1
Rev: src/post_modules/GTK2/source/gtkliststore.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmenu.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmenubar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmenushell.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmenutoolbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkmisc.pre:1.1
Rev: src/post_modules/GTK2/source/gtknotebook.pre:1.1
Rev: src/post_modules/GTK2/source/gtkobject.pre:1.1
Rev: src/post_modules/GTK2/source/gtkpaned.pre:1.1
Rev: src/post_modules/GTK2/source/gtkplug.pre:1.1
Rev: src/post_modules/GTK2/source/gtkprogress.pre:1.1
Rev: src/post_modules/GTK2/source/gtkprogressbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkradioaction.pre:1.1
Rev: src/post_modules/GTK2/source/gtkradiobutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkradiomenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtkradiotoolbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkrange.pre:1.1
Rev: src/post_modules/GTK2/source/gtkrcstyle.pre:1.1
Rev: src/post_modules/GTK2/source/gtkscale.pre:1.1
Rev: src/post_modules/GTK2/source/gtkscrollbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkscrolledwindow.pre:1.1
Rev: src/post_modules/GTK2/source/gtkselectiondata.pre:1.1
Rev: src/post_modules/GTK2/source/gtkseparator.pre:1.1
Rev: src/post_modules/GTK2/source/gtkseparatormenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtkseparatortoolitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtksettings.pre:1.1
Rev: src/post_modules/GTK2/source/gtksizegroup.pre:1.1
Rev: src/post_modules/GTK2/source/gtksocket.pre:1.1
Rev: src/post_modules/GTK2/source/gtkspinbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtkstatusbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkstyle.pre:1.1
Rev: src/post_modules/GTK2/source/gtktable.pre:1.1
Rev: src/post_modules/GTK2/source/gtktearoffmenuitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextattributes.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextbuffer.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextchildanchor.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextiter.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextmark.pre:1.1
Rev: src/post_modules/GTK2/source/gtktexttag.pre:1.1
Rev: src/post_modules/GTK2/source/gtktexttagtable.pre:1.1
Rev: src/post_modules/GTK2/source/gtktextview.pre:1.1
Rev: src/post_modules/GTK2/source/gtktoggleaction.pre:1.1
Rev: src/post_modules/GTK2/source/gtktogglebutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtktoggletoolbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtktoolbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtktoolbutton.pre:1.1
Rev: src/post_modules/GTK2/source/gtktoolitem.pre:1.1
Rev: src/post_modules/GTK2/source/gtktooltips.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreedragdest.inc:1.1
Rev: src/post_modules/GTK2/source/gtktreedragsource.inc:1.1
Rev: src/post_modules/GTK2/source/gtktreeiter.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreemodel.inc:1.1
Rev: src/post_modules/GTK2/source/gtktreemodel.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreepath.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreerowreference.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreeselection.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreesortable.inc:1.1
Rev: src/post_modules/GTK2/source/gtktreestore.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreeview.pre:1.1
Rev: src/post_modules/GTK2/source/gtktreeviewcolumn.pre:1.1
Rev: src/post_modules/GTK2/source/gtkuimanager.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvbuttonbox.pre:1.1
Rev: src/post_modules/GTK2/source/gtkviewport.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvpaned.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvscale.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvscrollbar.pre:1.1
Rev: src/post_modules/GTK2/source/gtkvseparator.pre:1.1
Rev: src/post_modules/GTK2/source/gtkwidget.pre:1.1
Rev: src/post_modules/GTK2/source/gtkwindow.pre:1.1
Rev: src/post_modules/GTK2/source/gtkwindowgroup.pre:1.1
Rev: src/post_modules/GTK2/source/pangoattrlist.pre:1.1
Rev: src/post_modules/GTK2/source/pangocontext.pre:1.1
Rev: src/post_modules/GTK2/source/pangofontdescription.pre:1.1
Rev: src/post_modules/GTK2/source/pangolayout.pre:1.1
Rev: src/post_modules/GTK2/source/pangolayoutiter.pre:1.1
Rev: src/post_modules/GTK2/source/pangolayoutline.pre:1.1
Rev: src/post_modules/GTK2/source/pangotabarray.pre:1.1
Rev: src/post_modules/GTK2/source/support.c:1.1

1: + /* + || This file is part of Pike. For copyright information see COPYRIGHT. + || Pike is distributed under GPL, LGPL and MPL. See the file COPYING + || for more information. + || $Id: encode_truecolor.c,v 1.1 2005/07/28 15:19:36 nilsson Exp $ + */    -  + static unsigned char swap_bits[256] = + { 0,128,64,192,32,160,96,224,16,144,80,208,48,176,112, +  240,8,136,72,200,40,168,104,232,24,152,88,216,56,184, +  120,248,4,132,68,196,36,164,100,228,20,148,84,212,52, +  180,116,244,12,140,76,204,44,172,108,236,28,156,92,220, +  60,188,124,252,2,130,66,194,34,162,98,226,18,146,82, +  210,50,178,114,242,10,138,74,202,42,170,106,234,26,154, +  90,218,58,186,122,250,6,134,70,198,38,166,102,230,22, +  150,86,214,54,182,118,246,14,142,78,206,46,174,110,238, +  30,158,94,222,62,190,126,254,1,129,65,193,33,161,97, +  225,17,145,81,209,49,177,113,241,9,137,73,201,41,169, +  105,233,25,153,89,217,57,185,121,249,5,133,69,197,37, +  165,101,229,21,149,85,213,53,181,117,245,13,141,77,205, +  45,173,109,237,29,157,93,221,61,189,125,253,3,131,67, +  195,35,163,99,227,19,147,83,211,51,179,115,243,11,139, +  75,203,43,171,107,235,27,155,91,219,59,187,123,251,7, +  135,71,199,39,167,103,231,23,151,87,215,55,183,119,247, +  15,143,79,207,47,175,111,239,31,159,95,223,63,191,127,255}; +  +  + static void encode_truecolor_24_rgb_swapped( rgb_group *s, +  unsigned char *d, +  int q, int w ) + { +  while(q--) +  { +  *(d++) = s->b; +  *(d++) = s->g; +  *(d++) = (s++)->r; +  } + } +  + static void encode_truecolor_24_rgb( rgb_group *s, +  unsigned char *d, +  int q, int w ) + { +  MEMCPY(d,(unsigned char *)s,q); + } +  + static void encode_truecolor_24_rgb_al32_swapped( rgb_group *s, +  unsigned char *d, +  int q, int w ) + { +  int l; +  while(q) +  { +  l=w; +  while(l--) +  { +  *(d++) = s->b; +  *(d++) = s->g; +  *(d++) = (s++)->r; +  q--; +  } +  d += (4-((w*3)&3))&3; +  } + } +  + static void encode_truecolor_24_rgb_al32( rgb_group *s, +  unsigned char *d, +  int q, int w ) + { +  int l; +  while(q) +  { +  for(l=0; l<(q/w)/3; l++) +  { +  MEMCPY(d,(unsigned char *)s,w*3); +  d += (w*3+3)&~3; +  } +  } + } +  +  + #define encode_truecolor_24_bgr encode_truecolor_24_rgb_swapped + #define encode_truecolor_24_bgr_swapped encode_truecolor_24_rgb + #define encode_truecolor_24_bgr_al32 encode_truecolor_24_rgb_al32_swapped + #define encode_truecolor_24_bgr_al32_swapped encode_truecolor_24_rgb_al32 +  + static void encode_truecolor_32_argb_swapped( rgb_group *s, +  unsigned char *d, +  int q,int w ) + { +  int *dp = (int *)d; + #if PIKE_BYTEORDER==1234 +  while(q--){ *(dp++) = (s->r<<16) | (s->g<<8) | (s)->b;s++;} + #else +  while(q--){ *(dp++) = ((s->r) | (s->g<<8) | (s)->b<<16)<<8;s++;} + #endif + } +  + static void encode_truecolor_32_argb( rgb_group *s, +  unsigned char *d, +  int q,int w ) + { +  int *dp = (int *)d; + #if PIKE_BYTEORDER==4321 +  while(q--) {*(dp++) = (s->r<<16) | (s->g<<8) | (s)->b;s++;} + #else +  while(q--) {*(dp++) = ((s->r) | (s->g<<8) | (s)->b<<16)<<8;s++;} + #endif + } +  + static void encode_truecolor_32_abgr( rgb_group *s, +  unsigned char *d, +  int q,int w ) + { +  while(q--) +  { +  *(d++) = 0; +  *(d++) = s->b; +  *(d++) = s->g; +  *(d++) = (s++)->r; +  } + } +  +  + static void encode_truecolor_32_abgr_swapped( rgb_group *s, +  unsigned char *d, +  int q,int w ) + { +  while(q--) +  { +  *(d++) = s->r; +  *(d++) = s->g; +  *(d++) = (s++)->b; +  *(d++) = 0; +  } + } +  + #define ENCODE_8(X,Y,Z) \ + static void encode_truecolor_##X##_##Y( rgb_group *s, unsigned char *d, int q,int w ) \ + { \ +  while(q--) \ +  {*(d++)=(Z);s++;} \ + } \ +  \ + static void encode_truecolor_##X##_##Y##_swapped( rgb_group *s, unsigned char *d, int q ,int w) \ + { \ +  while(q--) \ +  {*(d++)=(Z);s++;} \ + } +  +  + #if PIKE_BYTEORDER == 1234 + #define ENCODE_16(X,Y,Z) \ + static void encode_truecolor_##X##_##Y( rgb_group *s, unsigned char *d, int q,int w ) \ + { \ +  unsigned short *dp = (unsigned short *)d; \ +  while(q--) \ +  {*(dp++) = (Z);s++;} \ + } \ +  \ + static void encode_truecolor_##X##_##Y##_swapped( rgb_group *s, unsigned char *d, int q ,int w) \ + { \ +  while(q--) \ +  { \ +  unsigned short v = (Z); \ +  *(d++)=v&255; \ +  *(d++)=v>>8;s++; \ +  } \ + } + #else + #define ENCODE_16(X,Y,Z) \ + static void encode_truecolor_##X##_##Y( rgb_group *s, unsigned char *d, int q,int w ) \ + { \ +  while(q--) \ +  { \ +  unsigned short v = (Z); \ +  *(d++)=v>>8; \ +  *(d++)=v&255;s++; \ +  } \ + } \ +  \ + static void encode_truecolor_##X##_##Y##_swapped( rgb_group *s, unsigned char *d, int q ,int w) \ + { \ +  unsigned short *dp = (unsigned short *)d; \ +  while(q--) \ +  {*(dp++) = (Z);s++;} \ + } + #endif +  + ENCODE_16(565,rgb,(((s->r>>3)<<6) | (s->g>>2))<<5 | (s->b>>3)); + ENCODE_16(565,bgr,(((s->b>>3)<<6) | (s->g>>2))<<5 | (s->r>>3)); + ENCODE_16(555,rgb,(((s->r>>3)<<5) | (s->g>>3))<<5 | (s->b>>3)); + ENCODE_16(555,bgr,(((s->b>>3)<<5) | (s->g>>3))<<5 | (s->r>>3)); +  + ENCODE_8(232,rgb,(((s->r>>6)<<3) | (s->g>>5))<<2 | (s->b>>6)); + ENCODE_8(332,rgb,(((s->r>>5)<<3) | (s->g>>5))<<2 | (s->b>>6)); + ENCODE_8(242,rgb,(((s->r>>5)<<4) | (s->g>>4))<<2 | (s->b>>6)); + ENCODE_8(233,rgb,(((s->r>>5)<<3) | (s->g>>4))<<3 | (s->b>>5)); + ENCODE_8(232,bgr,(((s->b>>6)<<3) | (s->g>>5))<<2 | (s->r>>6)); + ENCODE_8(332,bgr,(((s->b>>5)<<3) | (s->g>>5))<<2 | (s->r>>6)); + ENCODE_8(242,bgr,(((s->b>>5)<<4) | (s->g>>4))<<2 | (s->r>>6)); + ENCODE_8(233,bgr,(((s->b>>5)<<3) | (s->g>>4))<<3 | (s->r>>5)); +  +  + static void encode_truecolor_generic(int rbits, int rshift, int gbits, +  int gshift, int bbits, int bshift, +  int bpp, int alignbits,int swap_bytes, +  struct image *img, unsigned char *dest, +  int len) + { +  unsigned char *d = dest; +  int x,y; +  rgb_group *s; +  s=img->img; +  +  if(!alignbits) alignbits=1; +  + #define OPTIMIZE(rb,rs,gb,gs,bb,bs,al,fun) do { \ +  if(rbits==rb && rshift==rs && gbits==gb && gshift==gs && \ +  bbits==bb && bshift==bs && alignbits==al) { \ +  DEBUG_PF(("Optimized case %s%s\n", #fun, swap_bytes?"_swapped":"")); \ +  if (swap_bytes) \ +  fun##_swapped(s, (void *)dest, img->xsize*img->ysize, img->xsize); \ +  else \ +  fun(s,(void *)dest,img->xsize*img->ysize,img->xsize); \ +  return; \ +  } \ +  } while(0) +  +  switch(bpp) +  { +  case 32: /* 4 alternatives */ +  OPTIMIZE(8,16,8,8,8,0,1,encode_truecolor_32_argb); +  OPTIMIZE(8,0,8,8,8,16,1,encode_truecolor_32_abgr); +  break; +  case 24: /* 8 alternatives */ +  OPTIMIZE(8,16,8,8,8,0,32,encode_truecolor_24_rgb_al32); +  OPTIMIZE(8,0,8,8,8,16,32,encode_truecolor_24_bgr_al32); +  OPTIMIZE(8,16,8,8,8,0,1,encode_truecolor_24_rgb); +  OPTIMIZE(8,0,8,8,8,16,1,encode_truecolor_24_bgr); +  break; +  case 16: /* 8 alternatives */ +  OPTIMIZE(5,11,6,5,5,0,1,encode_truecolor_565_rgb); +  OPTIMIZE(5,10,5,5,5,0,1,encode_truecolor_555_rgb); +  OPTIMIZE(5,0,6,5,5,11,1,encode_truecolor_565_bgr); +  OPTIMIZE(5,0,5,5,5,10,1,encode_truecolor_555_bgr); +  break; +  case 8: /* 16 alternatives */ +  OPTIMIZE(2,5,3,2,2,0,1,encode_truecolor_232_rgb); +  OPTIMIZE(3,5,3,2,2,0,1,encode_truecolor_332_rgb); +  OPTIMIZE(2,6,4,2,2,0,1,encode_truecolor_242_rgb); +  OPTIMIZE(2,6,3,3,3,0,1,encode_truecolor_233_rgb); +  OPTIMIZE(2,0,3,2,2,5,1,encode_truecolor_232_bgr); +  OPTIMIZE(3,0,3,2,2,5,1,encode_truecolor_332_bgr); +  OPTIMIZE(2,0,4,2,2,6,1,encode_truecolor_242_bgr); +  OPTIMIZE(2,0,3,3,3,6,1,encode_truecolor_233_bgr); +  break; +  } + #undef OPTIMIZE +  +  DEBUG_PF(("Generic encode_truecolor for r%dxg%dxb%d (%d bpp, shift=r%d,g%d,b%d)\n", +  rbits,gbits,bbits,bpp,rshift,gshift,bshift)); +  { +  int rfmask,gfmask,bfmask; +  int rfshift,gfshift,bfshift,rzshift,gzshift,bzshift; +  int bpshift,blinemod,bit; +  +  *d=0; +  +  rfshift=rshift-(sizeof(COLORTYPE)*8-rbits); +  gfshift=gshift-(sizeof(COLORTYPE)*8-gbits); +  bfshift=bshift-(sizeof(COLORTYPE)*8-bbits); +  if (rfshift<0) rzshift=-rfshift,rfshift=0; else rzshift=0; +  if (gfshift<0) gzshift=-gfshift,gfshift=0; else gzshift=0; +  if (bfshift<0) bzshift=-bfshift,bfshift=0; else bzshift=0; +  +  rfmask=(((1<<rbits)-1)<<(sizeof(COLORTYPE)*8-rbits)); +  gfmask=(((1<<gbits)-1)<<(sizeof(COLORTYPE)*8-gbits)); +  bfmask=(((1<<bbits)-1)<<(sizeof(COLORTYPE)*8-bbits)); +  bpshift=sizeof(unsigned long)*8-bpp; +  blinemod=alignbits-(((img->xsize*bpp+7)&~7)%alignbits); +  if(blinemod==alignbits) +  blinemod=0; +  else +  blinemod>>=3; +  +  bit=0; +  y = img->ysize; +  while (y--) +  { +  int bp; +  x=img->xsize; +  while (x--) +  { +  register unsigned long b = +  ((((s->r&rfmask)>>rzshift)<<rfshift)| +  (((s->g&gfmask)>>gzshift)<<gfshift)| +  (((s->b&bfmask)>>bzshift)<<bfshift))<<bpshift; +  bp = bpp; +  while (bp>8-bit) +  { +  if(bit) +  *d|=(unsigned char)(b>>(24+bit)); +  else +  *d=(unsigned char)(b>>24); +  b<<=8-bit; +  bp-=8-bit; +  bit=0; +  d++; +  } +  if(bit) +  *d|=b>>(24+bit); +  else +  *d=b>>24; +  bit+=bp; +  if (bit==8) ++d,bit=0; +  s++; +  } +  if(!y) +  break; +  if(bit) ++d,bit=0; +  bp=blinemod; +  while (bp--) *(++d)=0; +  } +  } +  +  if (swap_bytes) +  { +  d=dest; +  x=len; +  +  switch (bpp) +  { +  case 32: +  while (x>=4) +  { +  d[0]^=d[3],d[3]^=d[0],d[0]^=d[3]; +  d[1]^=d[2],d[2]^=d[1],d[1]^=d[2]; +  d+=4; +  x-=4; +  } +  break; +  case 24: +  while (x>=3) +  { +  d[0]^=d[2],d[2]^=d[0],d[0]^=d[2]; +  d+=3; +  x-=3; +  } +  break; +  case 16: +  while (x>=2) +  { +  d[0]^=d[1],d[1]^=d[0],d[0]^=d[1]; +  d+=2; +  x-=2; +  } +  break; +  case 1: +  while (x--) {*(d)=swap_bits[*d]; d++; } +  break; +  } +  } + } +  + static INLINE void examine_mask(unsigned int x, int *bits,int *shift) + { +  *bits=0; +  *shift=0; +  if (!x) return; +  while (!(x&1)) x>>=1,(*shift)++; +  while (x&1) x>>=1,(*bits)++; + } +  + void pgtk_encode_grey(struct image *i, unsigned char *dest, int bpp, int bpl ) + { +  int x, y; +  rgb_group *s = i->img; +  switch(bpp) +  { +  case 1: +  for(y=0; y<i->ysize; y++) +  { +  unsigned char *d = dest+y*bpl; +  for(x=0; x<i->xsize; x++,s++) +  *d = (s->r + (s->g<<1) + s->b)>>2; +  } +  return; +  case 2: +  for(y=0; y<i->ysize; y++) +  { +  unsigned short *d = (unsigned short *)(dest+y*bpl); +  for(x=0; x<i->xsize; x++,s++) +  *d = (s->r + (s->g<<1) + s->b)<<6; +  } +  return; +  default: +  Pike_error("This greyscale is to wide for me!\n"); +  } + } +  + void pgtk_encode_truecolor_masks(struct image *i, +  int bitspp, +  int pad, +  int byteorder, +  unsigned int red_mask, +  unsigned int green_mask, +  unsigned int blue_mask, +  unsigned char *buffer, +  int debug_len) + { +  int rbits,rshift,gbits,gshift,bbits,bshift; +  +  examine_mask(red_mask,&rbits,&rshift); +  examine_mask(green_mask,&gbits,&gshift); +  examine_mask(blue_mask,&bbits,&bshift); +  encode_truecolor_generic( rbits, rshift, gbits, gshift, bbits, bshift, +  bitspp, pad, byteorder, i, buffer, debug_len ); +  + }   Newline at end of file added.