comparison src/audacious/skin.c @ 4206:36338afdd736

skin_get_eq_spline_colors was rewritten without using pixmaps
author Cristi Magherusan <majeru@atheme.org>
date Mon, 21 Jan 2008 02:42:06 +0200
parents bc51ab3fecd5
children 41655c090c53
comparison
equal deleted inserted replaced
4204:f401e45cd4b3 4206:36338afdd736
1828 void 1828 void
1829 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19]) 1829 skin_get_eq_spline_colors(Skin * skin, guint32 colors[19])
1830 { 1830 {
1831 gint i; 1831 gint i;
1832 GdkPixbuf *pixbuf; 1832 GdkPixbuf *pixbuf;
1833 GdkImage *img;
1834 SkinPixmap *eqmainpm; 1833 SkinPixmap *eqmainpm;
1835 GdkPixmap *pixmap; 1834 guchar* pixels,*p;
1836 GdkGC *gc; 1835 guint rowstride, n_channels;
1837
1838 g_return_if_fail(skin != NULL); 1836 g_return_if_fail(skin != NULL);
1839 1837
1840 eqmainpm = &skin->pixmaps[SKIN_EQMAIN]; 1838 eqmainpm = &skin->pixmaps[SKIN_EQMAIN];
1841 if (eqmainpm->pixbuf && 1839 if (eqmainpm->pixbuf &&
1842 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313) 1840 eqmainpm->current_width >= 116 && eqmainpm->current_height >= 313)
1843 pixbuf = eqmainpm->pixbuf; 1841 pixbuf = eqmainpm->pixbuf;
1844 else 1842 else
1845 return; 1843 return;
1846 1844
1847 if (!GDK_IS_PIXBUF(pixbuf)) 1845 if (!GDK_IS_PIXBUF(pixbuf))
1848 return; 1846 return;
1849 1847
1850 pixmap = gdk_pixmap_new(NULL, eqmainpm->current_width, eqmainpm->current_height, 1848 pixels = gdk_pixbuf_get_pixels (pixbuf);
1851 gdk_rgb_get_visual()->depth); 1849 rowstride = gdk_pixbuf_get_rowstride (pixbuf);
1852 gc = gdk_gc_new(pixmap); 1850 n_channels = gdk_pixbuf_get_n_channels (pixbuf);
1853 gdk_draw_pixbuf(pixmap, gc, pixbuf, 0, 0, 0, 0, eqmainpm->current_width, eqmainpm->current_height,
1854 GDK_RGB_DITHER_MAX, 0, 0);
1855
1856 if (!(img = gdk_drawable_get_image(pixmap, 115, 294, 1, 19))) {
1857 g_object_unref(gc);
1858 g_object_unref(pixmap);
1859 return;
1860 }
1861
1862 for (i = 0; i < 19; i++) 1851 for (i = 0; i < 19; i++)
1863 colors[i] = gdk_image_get_pixel(img, 0, i); 1852 {
1864 1853 p = pixels + rowstride * (i + 294) + 115 * n_channels;
1865 g_object_unref(img); 1854 colors[i] = (p[0] << 16) | (p[1] << 8) | p[2];
1866 g_object_unref(gc); 1855 if(n_channels == 4) /* should we really treat the Alpha channel? */
1867 g_object_unref(pixmap); 1856 colors[i]= (colors[i] << 8) | p[3];
1857 }
1868 } 1858 }
1869 1859
1870 1860
1871 static void 1861 static void
1872 skin_draw_playlistwin_frame_top(Skin * skin, GdkPixbuf * pix, 1862 skin_draw_playlistwin_frame_top(Skin * skin, GdkPixbuf * pix,