Reindented to use the GNOME Indentation.

1999-10-18  Federico Mena Quintero  <federico@redhat.com>

	* src/*: Reindented to use the GNOME Indentation.
This commit is contained in:
Federico Mena Quintero
1999-10-18 19:29:45 +00:00
committed by Arturo Espinosa
parent 3b9835b5bb
commit 74268afdeb
16 changed files with 1139 additions and 1128 deletions

View File

@ -29,301 +29,297 @@
#define DEFAULT_HEIGHT 24 #define DEFAULT_HEIGHT 24
static const unsigned char default_image[] = { static const unsigned char default_image[] = {
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xae, 0xb3, 0xb3, 0xc6, 0xc9, 0xcd, 0xd7, 0xd4, 0xdf, 0x00, 0x00, 0x00, 0xae, 0xb3, 0xb3, 0xc6, 0xc9, 0xcd, 0xd7, 0xd4, 0xdf,
0xec, 0xde, 0xf3, 0xe7, 0xcb, 0xe9, 0xd9, 0xb5, 0xd3, 0x00, 0x00, 0x00, 0xec, 0xde, 0xf3, 0xe7, 0xcb, 0xe9, 0xd9, 0xb5, 0xd3, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xb1, 0xb7, 0xa5, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xb1, 0xb7, 0xa5,
0xb0, 0xb8, 0xad, 0xb3, 0xb9, 0xb6, 0xc1, 0xc6, 0xc8, 0xd5, 0xd3, 0xdc, 0xb0, 0xb8, 0xad, 0xb3, 0xb9, 0xb6, 0xc1, 0xc6, 0xc8, 0xd5, 0xd3, 0xdc,
0xec, 0xde, 0xf3, 0xe5, 0xca, 0xe6, 0xe0, 0xbb, 0xd7, 0xe1, 0xad, 0xc2, 0xec, 0xde, 0xf3, 0xe5, 0xca, 0xe6, 0xe0, 0xbb, 0xd7, 0xe1, 0xad, 0xc2,
0xe3, 0xac, 0xa3, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xe3, 0xac, 0xa3, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xca, 0xc1, 0xa4, 0xc5, 0xc7, 0xac, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xca, 0xc1, 0xa4, 0xc5, 0xc7, 0xac,
0xb7, 0xbe, 0xaf, 0xad, 0xb4, 0xaf, 0xbd, 0xc2, 0xc3, 0xd1, 0xd0, 0xd8, 0xb7, 0xbe, 0xaf, 0xad, 0xb4, 0xaf, 0xbd, 0xc2, 0xc3, 0xd1, 0xd0, 0xd8,
0xec, 0xde, 0xf3, 0xe5, 0xc7, 0xe4, 0xe0, 0xb6, 0xd1, 0xe7, 0xa9, 0xb4, 0xec, 0xde, 0xf3, 0xe5, 0xc7, 0xe4, 0xe0, 0xb6, 0xd1, 0xe7, 0xa9, 0xb4,
0xed, 0xcd, 0xb6, 0xd6, 0xcf, 0xae, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xed, 0xcd, 0xb6, 0xd6, 0xcf, 0xae, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0x00, 0x00, 0x00, 0xdf, 0xa7, 0x9f, 0xdd, 0xbf, 0xaa, 0xcf, 0xc5, 0xa9, 0x00, 0x00, 0x00, 0xdf, 0xa7, 0x9f, 0xdd, 0xbf, 0xaa, 0xcf, 0xc5, 0xa9,
0xc1, 0xc4, 0xac, 0xb2, 0xba, 0xaf, 0xb6, 0xbb, 0xbb, 0xcd, 0xce, 0xd4, 0xc1, 0xc4, 0xac, 0xb2, 0xba, 0xaf, 0xb6, 0xbb, 0xbb, 0xcd, 0xce, 0xd4,
0xec, 0xde, 0xf3, 0xe4, 0xc4, 0xe1, 0xe0, 0xaf, 0xc7, 0xea, 0xbc, 0xae, 0xec, 0xde, 0xf3, 0xe4, 0xc4, 0xe1, 0xe0, 0xaf, 0xc7, 0xea, 0xbc, 0xae,
0xe1, 0xd6, 0xb6, 0xc7, 0xcc, 0xae, 0xa2, 0xab, 0x9a, 0x00, 0x00, 0x00, 0xe1, 0xd6, 0xb6, 0xc7, 0xcc, 0xae, 0xa2, 0xab, 0x9a, 0x00, 0x00, 0x00,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0x00, 0x00, 0x00, 0xe3, 0xab, 0xc0, 0xe6, 0xa3, 0xa7, 0xdf, 0xba, 0xa8, 0x00, 0x00, 0x00, 0xe3, 0xab, 0xc0, 0xe6, 0xa3, 0xa7, 0xdf, 0xba, 0xa8,
0xcf, 0xc5, 0xa9, 0xbd, 0xc2, 0xae, 0xad, 0xb4, 0xaf, 0xc6, 0xc9, 0xcd, 0xcf, 0xc5, 0xa9, 0xbd, 0xc2, 0xae, 0xad, 0xb4, 0xaf, 0xc6, 0xc9, 0xcd,
0xec, 0xde, 0xf3, 0xe2, 0xbf, 0xdc, 0xe7, 0xa9, 0xb4, 0xe7, 0xd6, 0xb8, 0xec, 0xde, 0xf3, 0xe2, 0xbf, 0xdc, 0xe7, 0xa9, 0xb4, 0xe7, 0xd6, 0xb8,
0xc7, 0xcc, 0xae, 0xac, 0xb6, 0xa6, 0x9d, 0xa8, 0x9f, 0x00, 0x00, 0x00, 0xc7, 0xcc, 0xae, 0xac, 0xb6, 0xa6, 0x9d, 0xa8, 0x9f, 0x00, 0x00, 0x00,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xd9, 0xaf, 0xcf, 0xe1, 0xb4, 0xd2, 0xe2, 0xb0, 0xcb, 0xe4, 0xa9, 0xbb, 0xd9, 0xaf, 0xcf, 0xe1, 0xb4, 0xd2, 0xe2, 0xb0, 0xcb, 0xe4, 0xa9, 0xbb,
0xe2, 0xb2, 0xa6, 0xcf, 0xc5, 0xa9, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d, 0xe2, 0xb2, 0xa6, 0xcf, 0xc5, 0xa9, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d,
0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xed, 0xcd, 0xb6, 0xc7, 0xcc, 0xae, 0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xed, 0xcd, 0xb6, 0xc7, 0xcc, 0xae,
0xa6, 0xb1, 0xa3, 0x98, 0xa2, 0x9c, 0x8f, 0x97, 0x96, 0x7e, 0x84, 0x85, 0xa6, 0xb1, 0xa3, 0x98, 0xa2, 0x9c, 0x8f, 0x97, 0x96, 0x7e, 0x84, 0x85,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xe8, 0xc6, 0xe7, 0xe5, 0xc2, 0xe3, 0xe3, 0xbd, 0xdd, 0xe1, 0xb6, 0xd5, 0xe8, 0xc6, 0xe7, 0xe5, 0xc2, 0xe3, 0xe3, 0xbd, 0xdd, 0xe1, 0xb6, 0xd5,
0xe2, 0xb0, 0xcb, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xe2, 0xb0, 0xcb, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0x9d, 0xa8, 0x9f, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0x9d, 0xa8, 0x9f,
0x8f, 0x97, 0x96, 0x8b, 0x90, 0x92, 0x97, 0x9e, 0xa2, 0xa0, 0xa7, 0xae, 0x8f, 0x97, 0x96, 0x8b, 0x90, 0x92, 0x97, 0x9e, 0xa2, 0xa0, 0xa7, 0xae,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xe7, 0xd3, 0xed, 0xe8, 0xd1, 0xed, 0xe8, 0xce, 0xec, 0xe9, 0xcc, 0xeb, 0xe7, 0xd3, 0xed, 0xe8, 0xd1, 0xed, 0xe8, 0xce, 0xec, 0xe9, 0xcc, 0xeb,
0xe8, 0xc6, 0xe7, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xe8, 0xc6, 0xe7, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0x97, 0x9e, 0xa2, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0x97, 0x9e, 0xa2,
0xa7, 0xae, 0xb7, 0xb2, 0xb6, 0xc5, 0xba, 0xbc, 0xce, 0xbf, 0xbe, 0xd3, 0xa7, 0xae, 0xb7, 0xb2, 0xb6, 0xc5, 0xba, 0xbc, 0xce, 0xbf, 0xbe, 0xd3,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0, 0xe9, 0xdf, 0xf0,
0xe9, 0xdf, 0xf0, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xe9, 0xdf, 0xf0, 0x0d, 0x0d, 0x0d, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0xe1, 0xd2, 0xf7, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x0d, 0x0d, 0x0d, 0xe1, 0xd2, 0xf7,
0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7, 0xe1, 0xd2, 0xf7,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xca, 0xc7, 0xd2, 0xc5, 0xc4, 0xcd, 0xbf, 0xbf, 0xc7, 0xb8, 0xb9, 0xc0, 0xca, 0xc7, 0xd2, 0xc5, 0xc4, 0xcd, 0xbf, 0xbf, 0xc7, 0xb8, 0xb9, 0xc0,
0xae, 0xaf, 0xb6, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xae, 0xaf, 0xb6, 0x6a, 0x6a, 0x6a, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0xd5, 0xa8, 0xe1, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x6a, 0x6a, 0x6a, 0xd5, 0xa8, 0xe1,
0xd8, 0xb2, 0xe9, 0xd9, 0xb8, 0xed, 0xdb, 0xbd, 0xf0, 0xdc, 0xbf, 0xf1, 0xd8, 0xb2, 0xe9, 0xd9, 0xb8, 0xed, 0xdb, 0xbd, 0xf0, 0xdc, 0xbf, 0xf1,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0xa4, 0xa6, 0xac, 0xa8, 0xaa, 0xaf, 0xa0, 0xa6, 0xa8, 0x98, 0x9e, 0x9c, 0xa4, 0xa6, 0xac, 0xa8, 0xaa, 0xaf, 0xa0, 0xa6, 0xa8, 0x98, 0x9e, 0x9c,
0xa1, 0xa8, 0x9e, 0xb1, 0xb6, 0xa1, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d, 0xa1, 0xa8, 0x9e, 0xb1, 0xb6, 0xa1, 0x6a, 0x6a, 0x6a, 0x0d, 0x0d, 0x0d,
0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xc0, 0x8c, 0xad, 0xcc, 0x90, 0xb5, 0x0d, 0x0d, 0x0d, 0x6a, 0x6a, 0x6a, 0xc0, 0x8c, 0xad, 0xcc, 0x90, 0xb5,
0xd3, 0x94, 0xca, 0xd6, 0xa2, 0xdb, 0xd5, 0xa8, 0xe1, 0xcf, 0xa7, 0xdf, 0xd3, 0x94, 0xca, 0xd6, 0xa2, 0xdb, 0xd5, 0xa8, 0xe1, 0xcf, 0xa7, 0xdf,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0x00, 0x00, 0x00, 0x98, 0x9f, 0x9b, 0xa1, 0xa8, 0x9e, 0xac, 0xb3, 0xa0, 0x00, 0x00, 0x00, 0x98, 0x9f, 0x9b, 0xa1, 0xa8, 0x9e, 0xac, 0xb3, 0xa0,
0xb9, 0xb9, 0xa4, 0xd0, 0xb8, 0xa8, 0xc5, 0xb5, 0xb8, 0xb6, 0xbb, 0xad, 0xb9, 0xb9, 0xa4, 0xd0, 0xb8, 0xa8, 0xc5, 0xb5, 0xb8, 0xb6, 0xbb, 0xad,
0xe3, 0xd7, 0xb5, 0xdd, 0xb4, 0xa9, 0xcb, 0x89, 0xac, 0xc0, 0x8c, 0xad, 0xe3, 0xd7, 0xb5, 0xdd, 0xb4, 0xa9, 0xcb, 0x89, 0xac, 0xc0, 0x8c, 0xad,
0xc8, 0x91, 0xb5, 0xd1, 0x8d, 0xb7, 0xd3, 0x94, 0xca, 0x00, 0x00, 0x00, 0xc8, 0x91, 0xb5, 0xd1, 0x8d, 0xb7, 0xd3, 0x94, 0xca, 0x00, 0x00, 0x00,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0x00, 0x00, 0x00, 0xa1, 0xa7, 0x98, 0xb1, 0xb6, 0xa1, 0xbd, 0xb9, 0xa5, 0x00, 0x00, 0x00, 0xa1, 0xa7, 0x98, 0xb1, 0xb6, 0xa1, 0xbd, 0xb9, 0xa5,
0xd0, 0xb8, 0xa8, 0xca, 0xb5, 0xb7, 0xb8, 0xb1, 0xb1, 0xc2, 0xc8, 0xb2, 0xd0, 0xb8, 0xa8, 0xca, 0xb5, 0xb7, 0xb8, 0xb1, 0xb1, 0xc2, 0xc8, 0xb2,
0xe3, 0xd7, 0xb5, 0xe1, 0xbf, 0xaf, 0xdb, 0x92, 0x9a, 0xbe, 0x82, 0xa6, 0xe3, 0xd7, 0xb5, 0xe1, 0xbf, 0xaf, 0xdb, 0x92, 0x9a, 0xbe, 0x82, 0xa6,
0xc0, 0x8c, 0xad, 0xc8, 0x91, 0xb4, 0xc7, 0x8b, 0xb0, 0x00, 0x00, 0x00, 0xc0, 0x8c, 0xad, 0xc8, 0x91, 0xb4, 0xc7, 0x8b, 0xb0, 0x00, 0x00, 0x00,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xbc, 0xb6, 0xa1, 0xd0, 0xb8, 0xa8, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xbc, 0xb6, 0xa1, 0xd0, 0xb8, 0xa8,
0xcd, 0xb6, 0xb7, 0xc0, 0xb4, 0xb5, 0xb1, 0xb1, 0xaa, 0xca, 0xd1, 0xb4, 0xcd, 0xb6, 0xb7, 0xc0, 0xb4, 0xb5, 0xb1, 0xb1, 0xaa, 0xca, 0xd1, 0xb4,
0xe3, 0xd7, 0xb5, 0xe2, 0xc1, 0xb0, 0xdb, 0xa8, 0xa3, 0xd2, 0x8a, 0xa9, 0xe3, 0xd7, 0xb5, 0xe2, 0xc1, 0xb0, 0xdb, 0xa8, 0xa3, 0xd2, 0x8a, 0xa9,
0xb7, 0x7e, 0xa2, 0xbd, 0x89, 0xa9, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xb7, 0x7e, 0xa2, 0xbd, 0x89, 0xa9, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xc9, 0xaf, 0xaf, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xc9, 0xaf, 0xaf,
0xc5, 0xb5, 0xb8, 0xb8, 0xb1, 0xb1, 0xb6, 0xbb, 0xad, 0xd0, 0xd6, 0xb5, 0xc5, 0xb5, 0xb8, 0xb8, 0xb1, 0xb1, 0xb6, 0xbb, 0xad, 0xd0, 0xd6, 0xb5,
0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xaf, 0xdd, 0xb4, 0xa9, 0xdb, 0x92, 0x9a, 0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xaf, 0xdd, 0xb4, 0xa9, 0xdb, 0x92, 0x9a,
0xc6, 0x84, 0xa7, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xc6, 0x84, 0xa7, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xac, 0xaa, 0xa6, 0xbd, 0xc3, 0xb0, 0xd2, 0xd7, 0xb5, 0x00, 0x00, 0x00, 0xac, 0xaa, 0xa6, 0xbd, 0xc3, 0xb0, 0xd2, 0xd7, 0xb5,
0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xae, 0xdb, 0xb6, 0xa8, 0x00, 0x00, 0x00, 0xe3, 0xd7, 0xb5, 0xe2, 0xbf, 0xae, 0xdb, 0xb6, 0xa8, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff,
0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff, 0xff, 0x00, 0xff
}; };
static void static void
quit_func (GtkWidget *widget, gpointer dummy) quit_func (GtkWidget *widget, gpointer dummy)
{ {
gtk_main_quit (); gtk_main_quit ();
} }
static void
expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data) expose_func (GtkWidget *drawing_area, GdkEventExpose *event, gpointer data)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
gint x1, y1, x2, y2; gint x1, y1, x2, y2;
pixbuf = (GdkPixBuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf"); pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
if (pixbuf->art_pixbuf->has_alpha){ if (pixbuf->art_pixbuf->has_alpha) {
gdk_draw_rgb_32_image (drawing_area->window, gdk_draw_rgb_32_image (drawing_area->window,
drawing_area->style->black_gc, drawing_area->style->black_gc,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.width, event->area.width,
event->area.height, event->area.height,
GDK_RGB_DITHER_MAX, GDK_RGB_DITHER_MAX,
pixbuf->art_pixbuf->pixels pixbuf->art_pixbuf->pixels
+ (event->area.y * pixbuf->art_pixbuf->rowstride) + (event->area.y * pixbuf->art_pixbuf->rowstride)
+ (event->area.x * pixbuf->art_pixbuf->n_channels), + (event->area.x * pixbuf->art_pixbuf->n_channels),
pixbuf->art_pixbuf->rowstride); pixbuf->art_pixbuf->rowstride);
}else{ } else {
gdk_draw_rgb_image (drawing_area->window, gdk_draw_rgb_image (drawing_area->window,
drawing_area->style->white_gc, drawing_area->style->white_gc,
event->area.x, event->area.y, event->area.x, event->area.y,
event->area.width, event->area.width,
event->area.height, event->area.height,
GDK_RGB_DITHER_NORMAL, GDK_RGB_DITHER_NORMAL,
pixbuf->art_pixbuf->pixels pixbuf->art_pixbuf->pixels
+ (event->area.y * pixbuf->art_pixbuf->rowstride) + (event->area.y * pixbuf->art_pixbuf->rowstride)
+ (event->area.x * pixbuf->art_pixbuf->n_channels), + (event->area.x * pixbuf->art_pixbuf->n_channels),
pixbuf->art_pixbuf->rowstride); pixbuf->art_pixbuf->rowstride);
} }
} }
static void
config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data) config_func (GtkWidget *drawing_area, GdkEventConfigure *event, gpointer data)
{ {
GdkPixBuf *pixbuf, *spb; GdkPixbuf *pixbuf, *spb;
pixbuf = (GdkPixBuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf"); pixbuf = (GdkPixbuf *)gtk_object_get_data(GTK_OBJECT(drawing_area), "pixbuf");
g_print("X:%d Y:%d\n", event->width, event->height); g_print("X:%d Y:%d\n", event->width, event->height);
if (((event->width) != (pixbuf->art_pixbuf->width)) || if (((event->width) != (pixbuf->art_pixbuf->width)) ||
((event->height) != (pixbuf->art_pixbuf->height))) ((event->height) != (pixbuf->art_pixbuf->height)))
gdk_pixbuf_scale(pixbuf, event->width, event->height); gdk_pixbuf_scale(pixbuf, event->width, event->height);
} }
void static void
new_testrgb_window (GdkPixBuf *pixbuf) new_testrgb_window (GdkPixbuf *pixbuf)
{ {
GtkWidget *window; GtkWidget *window;
GtkWidget *vbox; GtkWidget *vbox;
GtkWidget *button; GtkWidget *button;
GtkWidget *drawing_area; GtkWidget *drawing_area;
gint w, h; gint w, h;
w = pixbuf->art_pixbuf->width; w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height; h = pixbuf->art_pixbuf->height;
window = gtk_widget_new (gtk_window_get_type (), window = gtk_widget_new (gtk_window_get_type (),
"GtkObject::user_data", NULL, "GtkObject::user_data", NULL,
"GtkWindow::type", GTK_WINDOW_TOPLEVEL, "GtkWindow::type", GTK_WINDOW_TOPLEVEL,
"GtkWindow::title", "testrgb", "GtkWindow::title", "testrgb",
"GtkWindow::allow_shrink", TRUE, "GtkWindow::allow_shrink", TRUE,
NULL); NULL);
gtk_signal_connect (GTK_OBJECT (window), "destroy", gtk_signal_connect (GTK_OBJECT (window), "destroy",
(GtkSignalFunc) quit_func, NULL); (GtkSignalFunc) quit_func, NULL);
vbox = gtk_vbox_new (FALSE, 0); vbox = gtk_vbox_new (FALSE, 0);
drawing_area = gtk_drawing_area_new (); drawing_area = gtk_drawing_area_new ();
gtk_drawing_area_size (GTK_DRAWING_AREA(drawing_area), w, h); gtk_drawing_area_size (GTK_DRAWING_AREA(drawing_area), w, h);
gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), drawing_area, TRUE, TRUE, 0);
gtk_signal_connect (GTK_OBJECT(drawing_area), "expose_event", gtk_signal_connect (GTK_OBJECT(drawing_area), "expose_event",
GTK_SIGNAL_FUNC(expose_func), NULL); GTK_SIGNAL_FUNC(expose_func), NULL);
gtk_signal_connect (GTK_OBJECT(drawing_area), "configure_event", gtk_signal_connect (GTK_OBJECT(drawing_area), "configure_event",
GTK_SIGNAL_FUNC (config_func), NULL); GTK_SIGNAL_FUNC (config_func), NULL);
gtk_object_set_data (GTK_OBJECT(drawing_area), "pixbuf", pixbuf); gtk_object_set_data (GTK_OBJECT(drawing_area), "pixbuf", pixbuf);
gtk_widget_show (drawing_area); gtk_widget_show (drawing_area);
button = gtk_button_new_with_label ("Quit"); button = gtk_button_new_with_label ("Quit");
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked", gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) gtk_widget_destroy, (GtkSignalFunc) gtk_widget_destroy,
GTK_OBJECT (window)); GTK_OBJECT (window));
gtk_widget_show (button); gtk_widget_show (button);
gtk_container_add (GTK_CONTAINER (window), vbox); gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox); gtk_widget_show (vbox);
gtk_widget_show (window); gtk_widget_show (window);
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int i; int i;
int found_valid = FALSE; int found_valid = FALSE;
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
gtk_init (&argc, &argv); gtk_init (&argc, &argv);
gdk_rgb_set_verbose (TRUE); gdk_rgb_set_verbose (TRUE);
gdk_rgb_init (); gdk_rgb_init ();
gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); gtk_widget_set_default_colormap (gdk_rgb_get_cmap ());
gtk_widget_set_default_visual (gdk_rgb_get_visual ()); gtk_widget_set_default_visual (gdk_rgb_get_visual ());
i = 1; i = 1;
if (argc == 1) if (argc == 1) {
{ pixbuf = gdk_pixbuf_load_image_from_rgb_d(default_image,
pixbuf = gdk_pixbuf_load_image_from_rgb_d(default_image, DEFAULT_WIDTH,
DEFAULT_WIDTH, DEFAULT_HEIGHT);
DEFAULT_HEIGHT); if (pixbuf) {
if (pixbuf) new_testrgb_window (pixbuf);
{ found_valid = TRUE;
new_testrgb_window (pixbuf); }
found_valid = TRUE; } else {
} for (i = 1; i < argc; i++) {
} else { pixbuf = gdk_pixbuf_load_image (argv[i]);
for (i = 1; i < argc; i++) pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
{
pixbuf = gdk_pixbuf_load_image (argv[i]);
pixbuf = gdk_pixbuf_rotate(pixbuf, 10.0);
if (pixbuf) if (pixbuf) {
{ new_testrgb_window (pixbuf);
new_testrgb_window (pixbuf); found_valid = TRUE;
found_valid = TRUE; }
} }
} }
}
if (found_valid) if (found_valid)
gtk_main (); gtk_main ();
return 0; return 0;
} }

View File

@ -1,3 +1,7 @@
1999-10-18 Federico Mena Quintero <federico@redhat.com>
* src/*: Reindented to use the GNOME Indentation.
1999-10-18 Havoc Pennington <hp@pobox.com> 1999-10-18 Havoc Pennington <hp@pobox.com>
* configure.in: Use AM_PATH_GLIB instead of glib-config directly * configure.in: Use AM_PATH_GLIB instead of glib-config directly

View File

@ -4,12 +4,12 @@
/* The optional cache interface */ /* The optional cache interface */
typedef struct { typedef struct {
int dummy; int dummy;
} GdkPixBufCache; } GdkPixbufCache;
GdkPixBufCache *gdk_pixbuf_cache_new (long image_cache_limit, GdkPixbufCache *gdk_pixbuf_cache_new (long image_cache_limit,
long pixmap_bitmap_cache_limit); long pixmap_bitmap_cache_limit);
void gdk_pixbuf_cache_destroy (GdkPixBufCache *cache); void gdk_pixbuf_cache_destroy (GdkPixbufCache *cache);
GdkPixBuf *gdk_pixbuf_cache_load_image (GdkPixBufCache *cache, GdkPixbuf *gdk_pixbuf_cache_load_image (GdkPixbufCache *cache,
const char *file); const char *file);
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* gdk-pixbuf-data.c: Code to load images into GdkPixBufs from constant data * gdk-pixbuf-data.c: Code to load images into GdkPixbufs from constant data
* *
* Author: * Author:
* Michael Fulbright (drmike@redhat.com) * Michael Fulbright (drmike@redhat.com)
@ -15,10 +15,10 @@
/* This function does all the work. */ /* This function does all the work. */
static GdkPixBuf * static GdkPixbuf *
_pixbuf_create_from_rgb_d(unsigned char *data, int w, int h) _pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
art_u8 *pixels; art_u8 *pixels;
@ -40,12 +40,10 @@ _pixbuf_create_from_rgb_d(unsigned char *data, int w, int h)
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height)
int rgb_width, int rgb_height)
{ {
g_return_val_if_fail (data != NULL, NULL); g_return_val_if_fail (data != NULL, NULL);
return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height); return _pixbuf_create_from_rgb_d(data, rgb_width, rgb_height);
} }

View File

@ -4,11 +4,7 @@
#include <gdk/gdk.h> #include <gdk/gdk.h>
#include <gdk-pixbuf.h> #include <gdk-pixbuf.h>
GdkPixBuf *gdk_pixbuf_rgb_from_drawable (GdkWindow *window, GdkPixbuf *gdk_pixbuf_rgb_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height);
gint x, gint y, GdkPixbuf *gdk_pixbuf_rgba_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height);
gint width, gint height);
GdkPixBuf *gdk_pixbuf_rgba_from_drawable (GdkWindow *window,
gint x, gint y,
gint width, gint height);
#endif /* _GDK_PIXBUF_DRAWABLE_H_ */ #endif /* _GDK_PIXBUF_DRAWABLE_H_ */

View File

@ -1,5 +1,5 @@
/* /*
* gdk-pixbuf-io.c: Code to load images into GdkPixBufs * gdk-pixbuf-io.c: Code to load images into GdkPixbufs
* *
* Author: * Author:
* Miguel de Icaza (miguel@gnu.org) * Miguel de Icaza (miguel@gnu.org)
@ -106,7 +106,7 @@ pixbuf_check_ppm (unsigned char *buffer, int size)
if (size < 20) if (size < 20)
return FALSE; return FALSE;
if (buffer [0] == 'P'){ if (buffer [0] == 'P') {
if (buffer [1] == '1' || if (buffer [1] == '1' ||
buffer [1] == '2' || buffer [1] == '2' ||
buffer [1] == '3' || buffer [1] == '3' ||
@ -122,8 +122,8 @@ static struct {
char *module_name; char *module_name;
gboolean (*format_check)(unsigned char *buffer, int size); gboolean (*format_check)(unsigned char *buffer, int size);
GModule *module; GModule *module;
GdkPixBuf *(*load)(FILE *f); GdkPixbuf *(*load)(FILE *f);
int (*save)(GdkPixBuf *p, FILE *f, ...); int (*save)(GdkPixbuf *p, FILE *f, ...);
} file_formats [] = { } file_formats [] = {
{ "png", pixbuf_check_png, NULL, NULL, NULL }, { "png", pixbuf_check_png, NULL, NULL, NULL },
{ "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL }, { "jpeg", pixbuf_check_jpeg, NULL, NULL, NULL },
@ -163,10 +163,10 @@ image_handler_load (int idx)
file_formats [idx].save = save_sym; file_formats [idx].save = save_sym;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_load_image (const char *file) gdk_pixbuf_load_image (const char *file)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
gint n, i; gint n, i;
FILE *f; FILE *f;
char buffer [128]; char buffer [128];
@ -176,17 +176,17 @@ gdk_pixbuf_load_image (const char *file)
return NULL; return NULL;
n = fread (&buffer, 1, sizeof (buffer), f); n = fread (&buffer, 1, sizeof (buffer), f);
if (n == 0){ if (n == 0) {
fclose (f); fclose (f);
return NULL; return NULL;
} }
for (i = 0; file_formats [i].module_name; i++){ for (i = 0; file_formats [i].module_name; i++) {
if ((*file_formats [i].format_check)(buffer, n)){ if ((*file_formats [i].format_check)(buffer, n)) {
if (!file_formats [i].load) if (!file_formats [i].load)
image_handler_load (i); image_handler_load (i);
if (!file_formats [i].load){ if (!file_formats [i].load) {
fclose (f); fclose (f);
return NULL; return NULL;
} }

View File

@ -1,14 +1,31 @@
/* /* GdkPixbuf library
* gdk-pixbuf.c: Resource management.
* *
* Authors: * Copyright (C) 1999 The Free Software Foundation
* Miguel de Icaza (miguel@gnu.org) *
* Mark Crichton (crichton@gimp.org) * Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Carsten Haitzler <raster@rasterman.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/ */
#include <config.h> #include <config.h>
#include <glib.h>
#include <math.h> #include <math.h>
#include <glib.h>
#include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_affine.h> #include <libart_lgpl/art_affine.h>
#include <libart_lgpl/art_pixbuf.h> #include <libart_lgpl/art_pixbuf.h>
@ -16,96 +33,96 @@
#include <libart_lgpl/art_alphagamma.h> #include <libart_lgpl/art_alphagamma.h>
#include "gdk-pixbuf.h" #include "gdk-pixbuf.h"
void void
gdk_pixbuf_destroy (GdkPixBuf *pixbuf) gdk_pixbuf_destroy (GdkPixbuf *pixbuf)
{ {
art_pixbuf_free (pixbuf->art_pixbuf); art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = NULL; pixbuf->art_pixbuf = NULL;
g_free (pixbuf); g_free (pixbuf);
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_new (ArtPixBuf *art_pixbuf, gdk_pixbuf_new (ArtPixBuf *art_pixbuf, GdkPixbufUnrefFunc *unref_fn)
GdkPixBufUnrefFunc *unref_fn)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
if (!art_pixbuf) if (!art_pixbuf)
return NULL; return NULL;
pixbuf = g_new (GdkPixBuf, 1); pixbuf = g_new (GdkPixbuf, 1);
pixbuf->ref_count = 1; pixbuf->ref_count = 1;
pixbuf->unref_fn = unref_fn; pixbuf->unref_fn = unref_fn;
pixbuf->art_pixbuf = art_pixbuf; pixbuf->art_pixbuf = art_pixbuf;
return pixbuf; return pixbuf;
} }
void void
gdk_pixbuf_ref (GdkPixBuf *pixbuf) gdk_pixbuf_ref (GdkPixbuf *pixbuf)
{ {
g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count > 0); g_return_if_fail (pixbuf->ref_count > 0);
pixbuf->ref_count++; pixbuf->ref_count++;
} }
void void
gdk_pixbuf_unref (GdkPixBuf *pixbuf) gdk_pixbuf_unref (GdkPixbuf *pixbuf)
{ {
g_return_if_fail (pixbuf != NULL); g_return_if_fail (pixbuf != NULL);
g_return_if_fail (pixbuf->ref_count > 0); g_return_if_fail (pixbuf->ref_count > 0);
pixbuf->ref_count--; pixbuf->ref_count--;
if (pixbuf->ref_count == 0) if (pixbuf->ref_count == 0)
gdk_pixbuf_destroy (pixbuf); gdk_pixbuf_destroy (pixbuf);
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_scale (const GdkPixBuf *pixbuf, gint w, gint h) gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h)
{ {
art_u8 *pixels; art_u8 *pixels;
gint rowstride; gint rowstride;
double affine[6]; double affine[6];
ArtAlphaGamma *alphagamma; ArtAlphaGamma *alphagamma;
ArtPixBuf *art_pixbuf = NULL; ArtPixBuf *art_pixbuf = NULL;
GdkPixBuf *copy = NULL; GdkPixbuf *copy = NULL;
alphagamma = NULL; alphagamma = NULL;
affine[1] = affine[2] = affine[4] = affine[5] = 0; affine[1] = affine[2] = affine[4] = affine[5] = 0;
affine[0] = w / (double)(pixbuf->art_pixbuf->width); affine[0] = w / (double)(pixbuf->art_pixbuf->width);
affine[3] = h / (double)(pixbuf->art_pixbuf->height); affine[3] = h / (double)(pixbuf->art_pixbuf->height);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */ /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3; rowstride = w * 3;
pixels = art_alloc (h * rowstride); pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride, art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf, pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma); affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha) if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */ /* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
copy = gdk_pixbuf_new (art_pixbuf, NULL); copy = gdk_pixbuf_new (art_pixbuf, NULL);
if (!copy) if (!copy)
art_free (pixels); art_free (pixels);
return copy; return copy;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf) gdk_pixbuf_duplicate (const GdkPixbuf *pixbuf)
{ {
GdkPixBuf *copy = g_new (GdkPixBuf, 1); GdkPixbuf *copy = g_new (GdkPixbuf, 1);
copy->ref_count = 1; copy->ref_count = 1;
copy->unref_fn = pixbuf->unref_fn; copy->unref_fn = pixbuf->unref_fn;
@ -114,59 +131,59 @@ gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf)
return copy; return copy;
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle) gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle)
{ {
art_u8 *pixels; art_u8 *pixels;
gint rowstride, w, h; gint rowstride, w, h;
gdouble rad; gdouble rad;
double rot[6], trans[6], affine[6]; double rot[6], trans[6], affine[6];
ArtAlphaGamma *alphagamma = NULL; ArtAlphaGamma *alphagamma = NULL;
ArtPixBuf *art_pixbuf = NULL; ArtPixBuf *art_pixbuf = NULL;
w = pixbuf->art_pixbuf->width; w = pixbuf->art_pixbuf->width;
h = pixbuf->art_pixbuf->height; h = pixbuf->art_pixbuf->height;
rad = (M_PI * angle / 180.0); rad = (M_PI * angle / 180.0);
rot[0] = cos(rad); rot[0] = cos(rad);
rot[1] = sin(rad); rot[1] = sin(rad);
rot[2] = -sin(rad); rot[2] = -sin(rad);
rot[3] = cos(rad); rot[3] = cos(rad);
rot[4] = rot[5] = 0; rot[4] = rot[5] = 0;
trans[0] = trans[3] = 1; trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0; trans[1] = trans[2] = 0;
trans[4] = -(double)w / 2.0; trans[4] = -(double)w / 2.0;
trans[5] = -(double)h / 2.0; trans[5] = -(double)h / 2.0;
art_affine_multiply(rot, trans, rot); art_affine_multiply(rot, trans, rot);
trans[0] = trans[3] = 1; trans[0] = trans[3] = 1;
trans[1] = trans[2] = 0; trans[1] = trans[2] = 0;
trans[4] = (double)w / 2.0; trans[4] = (double)w / 2.0;
trans[5] = (double)h / 2.0; trans[5] = (double)h / 2.0;
art_affine_multiply(affine, rot, trans); art_affine_multiply(affine, rot, trans);
g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2], g_print("Affine: %e %e %e %e %e %e\n", affine[0], affine[1], affine[2],
affine[3], affine[4], affine[5]); affine[3], affine[4], affine[5]);
/* rowstride = w * pixbuf->art_pixbuf->n_channels; */ /* rowstride = w * pixbuf->art_pixbuf->n_channels; */
rowstride = w * 3; rowstride = w * 3;
pixels = art_alloc (h * rowstride); pixels = art_alloc (h * rowstride);
art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride, art_rgb_pixbuf_affine (pixels, 0, 0, w, h, rowstride,
pixbuf->art_pixbuf, pixbuf->art_pixbuf,
affine, ART_FILTER_NEAREST, alphagamma); affine, ART_FILTER_NEAREST, alphagamma);
if (pixbuf->art_pixbuf->has_alpha) if (pixbuf->art_pixbuf->has_alpha)
/* should be rgba */ /* should be rgba */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
else else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride); art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, rowstride);
art_pixbuf_free (pixbuf->art_pixbuf); art_pixbuf_free (pixbuf->art_pixbuf);
pixbuf->art_pixbuf = art_pixbuf; pixbuf->art_pixbuf = art_pixbuf;
return pixbuf; return pixbuf;
} }

View File

@ -1,34 +1,72 @@
#ifndef _GDK_PIXBUF_H_ /* GdkPixbuf library
#define _GDK_PIXBUF_H_ *
* Copyright (C) 1999 The Free Software Foundation
*
* Authors: Mark Crichton <crichton@gimp.org>
* Miguel de Icaza <miguel@gnu.org>
* Federico Mena-Quintero <federico@gimp.org>
* Carsten Haitzler <raster@rasterman.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef GDK_PIXBUF_H
#define GDK_PIXBUF_H
#include <libart_lgpl/art_misc.h> #include <libart_lgpl/art_misc.h>
#include <libart_lgpl/art_pixbuf.h> #include <libart_lgpl/art_pixbuf.h>
#include <glib.h> #include <glib.h>
typedef struct _GdkPixBuf GdkPixBuf; #ifdef __cplusplus
typedef void (*GdkPixBufUnrefFunc) (GdkPixBuf *pixbuf); extern "C" {
#endif
struct _GdkPixBuf
{
int ref_count; typedef struct _GdkPixbuf GdkPixbuf;
ArtPixBuf *art_pixbuf; typedef void (* GdkPixbufUnrefFunc) (GdkPixbuf *pixbuf);
GdkPixBufUnrefFunc *unref_fn;
struct _GdkPixbuf {
int ref_count;
ArtPixBuf *art_pixbuf;
GdkPixbufUnrefFunc *unref_fn;
}; };
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
GdkPixBuf *gdk_pixbuf_new (ArtPixBuf *art_pixbuf,
GdkPixBufUnrefFunc *unref_fn);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_duplicate (const GdkPixBuf *pixbuf);
GdkPixBuf *gdk_pixbuf_scale (const GdkPixBuf *pixbuf, gint w, gint h);
GdkPixBuf *gdk_pixbuf_rotate (GdkPixBuf *pixbuf, gdouble angle);
void gdk_pixbuf_destroy (GdkPixBuf *pixbuf); GdkPixbuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
GdkPixBuf *gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, GdkPixbuf *gdk_pixbuf_new (ArtPixBuf *art_pixbuf, GdkPixbufUnrefFunc *unref_fn);
int rgb_width, int rgb_height);
void gdk_pixbuf_ref (GdkPixbuf *pixbuf);
void gdk_pixbuf_unref (GdkPixbuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */ GdkPixbuf *gdk_pixbuf_duplicate (const GdkPixbuf *pixbuf);
GdkPixbuf *gdk_pixbuf_scale (const GdkPixbuf *pixbuf, gint w, gint h);
GdkPixbuf *gdk_pixbuf_rotate (GdkPixbuf *pixbuf, gdouble angle);
void gdk_pixbuf_destroy (GdkPixbuf *pixbuf);
GdkPixbuf *gdk_pixbuf_load_image_from_rgb_d (unsigned char *data, int rgb_width, int rgb_height);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/* /*
* io-bmp.c: GdkPixBuf I/O for BMP files. * io-bmp.c: GdkPixbuf I/O for BMP files.
* *
* Copyright (C) 1999 Mark Crichton * Copyright (C) 1999 Mark Crichton
* Author: Mark Crichton <crichton@gimp.org> * Author: Mark Crichton <crichton@gimp.org>
@ -30,18 +30,18 @@
/* Loosely based off the BMP loader from The GIMP, hence it's complexity */ /* Loosely based off the BMP loader from The GIMP, hence it's complexity */
/* Shared library entry point */ /* Shared library entry point */
GdkPixBuf *image_load(FILE * f) GdkPixbuf *image_load(FILE * f)
{ {
art_u8 *pixels; art_u8 *pixels;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
/* Ok, now stuff the GdkPixBuf with goodies */ /* Ok, now stuff the GdkPixbuf with goodies */
if (is_trans) if (is_trans)
art_pixbuf = art_pixbuf_new_rgba (pixels, w, h, (w * 4)); art_pixbuf = art_pixbuf_new_rgba (pixels, w, h, (w * 4));
else else
art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w * 3)); art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w * 3));
/* Ok, I'm anal...shoot me */ /* Ok, I'm anal...shoot me */
return gdk_pixbuf_new (art_pixbuf, NULL); return gdk_pixbuf_new (art_pixbuf, NULL);
} }

View File

@ -1,5 +1,5 @@
/* /*
* io-gif.c: GdkPixBuf I/O for GIF files. * io-gif.c: GdkPixbuf I/O for GIF files.
* ...second verse, same as the first... * ...second verse, same as the first...
* *
* Copyright (C) 1999 Mark Crichton * Copyright (C) 1999 Mark Crichton
@ -29,148 +29,149 @@
#include <gif_lib.h> #include <gif_lib.h>
/* Shared library entry point */ /* Shared library entry point */
GdkPixBuf *image_load(FILE * f) GdkPixbuf *
image_load(FILE *f)
{ {
gint fn, is_trans = FALSE; gint fn, is_trans = FALSE;
gint done = 0; gint done = 0;
gint t_color = -1; gint t_color = -1;
gint w, h, i, j; gint w, h, i, j;
art_u8 *pixels, *tmpptr; art_u8 *pixels, *tmpptr;
GifFileType *gif; GifFileType *gif;
GifRowType *rows; GifRowType *rows;
GifRecordType rec; GifRecordType rec;
ColorMapObject *cmap; ColorMapObject *cmap;
int intoffset[] = int intoffset[] =
{0, 4, 2, 1}; {0, 4, 2, 1};
int intjump[] = int intjump[] =
{8, 8, 4, 2}; {8, 8, 4, 2};
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
g_return_val_if_fail(f != NULL, NULL); g_return_val_if_fail(f != NULL, NULL);
fn = fileno(f); fn = fileno(f);
/* lseek(fn, 0, 0);*/ /* lseek(fn, 0, 0);*/
gif = DGifOpenFileHandle(fn); gif = DGifOpenFileHandle(fn);
if (!gif) { if (!gif) {
g_error("DGifOpenFilehandle FAILED"); g_error("DGifOpenFilehandle FAILED");
PrintGifError();
return NULL;
}
/* Now we do the ungodly mess of loading a GIF image
* I used to remember when I liked this file format...
* of course, I still coded in assembler then.
* This comes from gdk_imlib, with some cleanups.
*/
do {
if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {
PrintGifError();
rec = TERMINATE_RECORD_TYPE;
}
if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done)) {
if (DGifGetImageDesc(gif) == GIF_ERROR) {
PrintGifError(); PrintGifError();
rec = TERMINATE_RECORD_TYPE;
}
w = gif->Image.Width;
h = gif->Image.Height;
rows = g_malloc0(h * sizeof(GifRowType *));
if (!rows) {
DGifCloseFile(gif);
return NULL; return NULL;
}
for (i = 0; i < h; i++) {
rows[i] = g_malloc0(w * sizeof(GifPixelType));
if (!rows[i]) {
DGifCloseFile(gif);
for (i = 0; i < h; i++)
if (rows[i])
g_free(rows[i]);
free(rows);
return NULL;
}
}
if (gif->Image.Interlace) {
for (i = 0; i < 4; i++) {
for (j = intoffset[i]; j < h; j += intjump[i])
DGifGetLine(gif, rows[j], w);
}
} else {
for (i = 0; i < h; i++)
DGifGetLine(gif, rows[i], w);
}
done = 1;
} else if (rec == EXTENSION_RECORD_TYPE) {
gint ext_code;
GifByteType *ext;
DGifGetExtension(gif, &ext_code, &ext);
while (ext) {
if ((ext_code == 0xf9) &&
(ext[1] & 1) && (t_color < 0)) {
is_trans = TRUE;
t_color = (gint) ext[4];
}
ext = NULL;
DGifGetExtensionNext(gif, &ext);
}
} }
} /* Now we do the ungodly mess of loading a GIF image
while (rec != TERMINATE_RECORD_TYPE); * I used to remember when I liked this file format...
* of course, I still coded in assembler then.
* This comes from gdk_imlib, with some cleanups.
*/
/* Ok, we're loaded, now to convert from indexed -> RGB do {
* with alpha if necessary if (DGifGetRecordType(gif, &rec) == GIF_ERROR) {
*/ PrintGifError();
rec = TERMINATE_RECORD_TYPE;
}
if ((rec == IMAGE_DESC_RECORD_TYPE) && (!done)) {
if (DGifGetImageDesc(gif) == GIF_ERROR) {
PrintGifError();
rec = TERMINATE_RECORD_TYPE;
}
w = gif->Image.Width;
h = gif->Image.Height;
rows = g_malloc0(h * sizeof(GifRowType *));
if (!rows) {
DGifCloseFile(gif);
return NULL;
}
for (i = 0; i < h; i++) {
rows[i] = g_malloc0(w * sizeof(GifPixelType));
if (!rows[i]) {
DGifCloseFile(gif);
for (i = 0; i < h; i++)
if (rows[i])
g_free(rows[i]);
free(rows);
return NULL;
}
}
if (gif->Image.Interlace) {
for (i = 0; i < 4; i++) {
for (j = intoffset[i]; j < h; j += intjump[i])
DGifGetLine(gif, rows[j], w);
}
} else {
for (i = 0; i < h; i++)
DGifGetLine(gif, rows[i], w);
}
done = 1;
} else if (rec == EXTENSION_RECORD_TYPE) {
gint ext_code;
GifByteType *ext;
if (is_trans) DGifGetExtension(gif, &ext_code, &ext);
pixels = art_alloc(h * w * 4); while (ext) {
else if ((ext_code == 0xf9) &&
pixels = art_alloc(h * w * 3); (ext[1] & 1) && (t_color < 0)) {
tmpptr = pixels; is_trans = TRUE;
t_color = (gint) ext[4];
if (!pixels) }
return NULL; ext = NULL;
DGifGetExtensionNext(gif, &ext);
/* The meat of the transformation */ }
/* Get the right palette */ }
cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);
/* Unindex the data, and pack it in RGB(A) order.
* Note for transparent GIFs, the alpha is set to 0
* for the transparent color, and 0xFF for everything else.
* I think that's right...
*/
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
tmpptr[0] = cmap->Colors[rows[i][j]].Red;
tmpptr[1] = cmap->Colors[rows[i][j]].Green;
tmpptr[2] = cmap->Colors[rows[i][j]].Blue;
if (is_trans && (rows[i][j] == t_color))
tmpptr[3] = 0;
else
tmpptr[3] = 0xFF;
tmpptr += (is_trans ? 4 : 3);
} }
g_free(rows[i]); while (rec != TERMINATE_RECORD_TYPE);
}
g_free(rows);
if (is_trans) /* Ok, we're loaded, now to convert from indexed -> RGB
art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4)); * with alpha if necessary
else */
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL); if (is_trans)
pixels = art_alloc(h * w * 4);
else
pixels = art_alloc(h * w * 3);
tmpptr = pixels;
/* Ok, I'm anal...shoot me */ if (!pixels)
if (!pixbuf) return NULL;
art_free(pixels);
return pixbuf; /* The meat of the transformation */
/* Get the right palette */
cmap = (gif->Image.ColorMap ? gif->Image.ColorMap : gif->SColorMap);
/* Unindex the data, and pack it in RGB(A) order.
* Note for transparent GIFs, the alpha is set to 0
* for the transparent color, and 0xFF for everything else.
* I think that's right...
*/
for (i = 0; i < h; i++) {
for (j = 0; j < w; j++) {
tmpptr[0] = cmap->Colors[rows[i][j]].Red;
tmpptr[1] = cmap->Colors[rows[i][j]].Green;
tmpptr[2] = cmap->Colors[rows[i][j]].Blue;
if (is_trans && (rows[i][j] == t_color))
tmpptr[3] = 0;
else
tmpptr[3] = 0xFF;
tmpptr += (is_trans ? 4 : 3);
}
g_free(rows[i]);
}
g_free(rows);
if (is_trans)
art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
/* Ok, I'm anal...shoot me */
if (!pixbuf)
art_free(pixels);
return pixbuf;
} }
image_save() {} image_save() {}

View File

@ -1,5 +1,5 @@
/* /*
io-jpeg.c: GdkPixBuf loader for jpeg files. io-jpeg.c: GdkPixbuf loader for jpeg files.
Based on io-jpeg from gdk_imlib, but not much. Based on io-jpeg from gdk_imlib, but not much.
@ -19,10 +19,9 @@
#include <jpeglib.h> #include <jpeglib.h>
/* error handler data */ /* error handler data */
struct iojpeg_JPEG_error_mgr struct iojpeg_JPEG_error_mgr {
{
struct jpeg_error_mgr pub; struct jpeg_error_mgr pub;
sigjmp_buf setjmp_buffer; sigjmp_buf setjmp_buffer;
}; };
static void static void
@ -39,17 +38,18 @@ g_JPEGFatalErrorHandler(j_common_ptr cinfo)
return; return;
} }
GdkPixBuf *image_load(FILE *f) GdkPixbuf *
image_load(FILE *f)
{ {
int w,h,i,j; int w,h,i,j;
art_u8 *pixels=NULL, *dptr; art_u8 *pixels=NULL, *dptr;
unsigned char *lines[4], /* Used to expand rows, via rec_outbuf_height, from unsigned char *lines[4], /* Used to expand rows, via rec_outbuf_height, from
the header file: the header file:
"* Usually rec_outbuf_height will be 1 or 2, at most 4." */ "* Usually rec_outbuf_height will be 1 or 2, at most 4." */
**lptr; **lptr;
struct jpeg_decompress_struct cinfo; struct jpeg_decompress_struct cinfo;
struct iojpeg_JPEG_error_mgr jerr; struct iojpeg_JPEG_error_mgr jerr;
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
/* setup error handler */ /* setup error handler */
cinfo.err = jpeg_std_error(&(jerr.pub)); cinfo.err = jpeg_std_error(&(jerr.pub));

View File

@ -1,5 +1,5 @@
/* /*
* io-png.c: GdkPixBuf I/O for PNG files. * io-png.c: GdkPixbuf I/O for PNG files.
* Copyright (C) 1999 Mark Crichton * Copyright (C) 1999 Mark Crichton
* Author: Mark Crichton <crichton@gimp.org> * Author: Mark Crichton <crichton@gimp.org>
* *
@ -26,214 +26,216 @@
#include <png.h> #include <png.h>
/* Shared library entry point */ /* Shared library entry point */
GdkPixBuf *image_load(FILE * f) GdkPixbuf *
image_load (FILE *f)
{ {
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr, end_info; png_infop info_ptr, end_info;
gint i, depth, ctype, inttype, passes, bpp; /* bpp = BYTES/pixel */ gint i, depth, ctype, inttype, passes, bpp; /* bpp = BYTES/pixel */
png_uint_32 w, h, x, y; png_uint_32 w, h, x, y;
png_bytepp rows; png_bytepp rows;
art_u8 *pixels, *temp, *rowdata; art_u8 *pixels, *temp, *rowdata;
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
g_return_val_if_fail (f != NULL, NULL); g_return_val_if_fail (f != NULL, NULL);
png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL); NULL, NULL, NULL);
if (!png_ptr) if (!png_ptr)
return NULL; return NULL;
info_ptr = png_create_info_struct (png_ptr); info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr) { if (!info_ptr) {
png_destroy_read_struct (&png_ptr, NULL, NULL); png_destroy_read_struct (&png_ptr, NULL, NULL);
return NULL; return NULL;
} }
end_info = png_create_info_struct (png_ptr); end_info = png_create_info_struct (png_ptr);
if (!end_info) { if (!end_info) {
png_destroy_read_struct (&png_ptr, &info_ptr, NULL); png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
return NULL; return NULL;
} }
if (setjmp (png_ptr->jmpbuf)) { if (setjmp (png_ptr->jmpbuf)) {
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
return NULL; return NULL;
} }
png_init_io (png_ptr, f); png_init_io (png_ptr, f);
png_read_info (png_ptr, info_ptr); png_read_info (png_ptr, info_ptr);
png_get_IHDR (png_ptr, info_ptr, &w, &h, &depth, &ctype, &inttype, png_get_IHDR (png_ptr, info_ptr, &w, &h, &depth, &ctype, &inttype,
NULL, NULL); NULL, NULL);
/* Ok, we want to work with 24 bit images. /* Ok, we want to work with 24 bit images.
* However, PNG can vary depth per channel. * However, PNG can vary depth per channel.
* So, we use the png_set_expand function to expand * So, we use the png_set_expand function to expand
* everything into a format libart expects. * everything into a format libart expects.
* We also use png_set_strip_16 to reduce down to 8 bit/chan. * We also use png_set_strip_16 to reduce down to 8 bit/chan.
*/ */
if (ctype == PNG_COLOR_TYPE_PALETTE && depth <= 8) if (ctype == PNG_COLOR_TYPE_PALETTE && depth <= 8)
png_set_expand (png_ptr); png_set_expand (png_ptr);
if (ctype == PNG_COLOR_TYPE_GRAY && depth < 8) if (ctype == PNG_COLOR_TYPE_GRAY && depth < 8)
png_set_expand (png_ptr); png_set_expand (png_ptr);
if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) { if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS)) {
png_set_expand (png_ptr); png_set_expand (png_ptr);
g_warning ("FIXME: We are going to crash"); g_warning ("FIXME: We are going to crash");
} }
if (depth == 16) if (depth == 16)
png_set_strip_16 (png_ptr); png_set_strip_16 (png_ptr);
/* We also have png "packing" bits into bytes if < 8 */ /* We also have png "packing" bits into bytes if < 8 */
if (depth < 8) if (depth < 8)
png_set_packing (png_ptr); png_set_packing (png_ptr);
/* Lastly, if the PNG is greyscale, convert to RGB */ /* Lastly, if the PNG is greyscale, convert to RGB */
if (ctype == PNG_COLOR_TYPE_GRAY || ctype == PNG_COLOR_TYPE_GRAY_ALPHA) if (ctype == PNG_COLOR_TYPE_GRAY || ctype == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb (png_ptr); png_set_gray_to_rgb (png_ptr);
/* ...and if we're interlaced... */ /* ...and if we're interlaced... */
passes = png_set_interlace_handling (png_ptr); passes = png_set_interlace_handling (png_ptr);
/* Update our info structs */ /* Update our info structs */
png_read_update_info (png_ptr, info_ptr); png_read_update_info (png_ptr, info_ptr);
/* Allocate some memory and set up row array */ /* Allocate some memory and set up row array */
/* This "inhales vigorously"... */ /* This "inhales vigorously"... */
if (ctype & PNG_COLOR_MASK_ALPHA) if (ctype & PNG_COLOR_MASK_ALPHA)
bpp = 4; bpp = 4;
else else
bpp = 3; bpp = 3;
pixels = art_alloc (w * h * bpp); pixels = art_alloc (w * h * bpp);
rows = g_malloc (h * sizeof(png_bytep)); rows = g_malloc (h * sizeof(png_bytep));
if (!pixels || !rows) { if (!pixels || !rows) {
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
return NULL;
}
/* Icky code, but it has to be done... */
for (i = 0; i < h; i++) {
if ((rows[i] = g_malloc (w * sizeof (art_u8) * bpp)) == NULL) {
int n;
for (n = 0; n < i; n++)
g_free (rows[i]);
g_free (rows);
art_free (pixels);
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
return NULL;
}
}
/* And we FINALLY get here... */
png_read_image (png_ptr, rows);
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); png_destroy_read_struct (&png_ptr, &info_ptr, &end_info);
return NULL;
} /* Now stuff the bytes into pixels & free rows[y] */
/* Icky code, but it has to be done... */
for (i = 0; i < h; i++) { temp = pixels;
if ((rows[i] = g_malloc (w * sizeof (art_u8) * bpp)) == NULL) {
int n; for (y = 0; y < h; y++) {
for (n = 0; n < i; n++) (png_bytep) rowdata = rows[y];
g_free (rows[i]); for (x = 0; x < w; x++) {
g_free (rows); temp[0] = rowdata[(x * bpp)];
art_free (pixels); temp[1] = rowdata[(x * bpp) + 1];
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); temp[2] = rowdata[(x * bpp) + 2];
return NULL; if (bpp == 4)
temp[3] = rowdata[(x * bpp) + 3];
temp += bpp;
}
g_free (rows[y]);
} }
} g_free (rows);
/* And we FINALLY get here... */ if (ctype & PNG_COLOR_MASK_ALPHA)
png_read_image (png_ptr, rows); art_pixbuf = art_pixbuf_new_rgba (pixels, w, h, (w * 4));
png_destroy_read_struct (&png_ptr, &info_ptr, &end_info); else
art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w * 3));
/* Now stuff the bytes into pixels & free rows[y] */ pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
temp = pixels; if (!pixbuf)
art_free (pixels);
for (y = 0; y < h; y++) { return pixbuf;
(png_bytep) rowdata = rows[y];
for (x = 0; x < w; x++) {
temp[0] = rowdata[(x * bpp)];
temp[1] = rowdata[(x * bpp) + 1];
temp[2] = rowdata[(x * bpp) + 2];
if (bpp == 4)
temp[3] = rowdata[(x * bpp) + 3];
temp += bpp;
}
g_free (rows[y]);
}
g_free (rows);
if (ctype & PNG_COLOR_MASK_ALPHA)
art_pixbuf = art_pixbuf_new_rgba (pixels, w, h, (w * 4));
else
art_pixbuf = art_pixbuf_new_rgb (pixels, w, h, (w * 3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
if (!pixbuf)
art_free (pixels);
return pixbuf;
} }
int image_save(GdkPixBuf *pixbuf, FILE *file) int
image_save (GdkPixbuf *pixbuf, FILE *file)
{ {
png_structp png_ptr; png_structp png_ptr;
png_infop info_ptr; png_infop info_ptr;
art_u8 *data; art_u8 *data;
gint y, h, w; gint y, h, w;
png_bytepp row_ptr; png_bytepp row_ptr;
png_color_8 sig_bit; png_color_8 sig_bit;
gint type; gint type;
g_return_val_if_fail(file != NULL, FALSE); g_return_val_if_fail(file != NULL, FALSE);
g_return_val_if_fail(pixbuf != NULL, FALSE); g_return_val_if_fail(pixbuf != NULL, FALSE);
h = pixbuf->art_pixbuf->height; h = pixbuf->art_pixbuf->height;
w = pixbuf->art_pixbuf->width; w = pixbuf->art_pixbuf->width;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL); NULL, NULL, NULL);
if (png_ptr == NULL) { if (png_ptr == NULL) {
fclose(file); fclose(file);
return FALSE; return FALSE;
} }
info_ptr = png_create_info_struct(png_ptr); info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL) { if (info_ptr == NULL) {
fclose(file); fclose(file);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL); png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return FALSE; return FALSE;
} }
if (setjmp(png_ptr->jmpbuf)) { if (setjmp(png_ptr->jmpbuf)) {
fclose(file); fclose(file);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL); png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return FALSE; return FALSE;
} }
png_init_io(png_ptr, file); png_init_io(png_ptr, file);
if (pixbuf->art_pixbuf->has_alpha) { if (pixbuf->art_pixbuf->has_alpha) {
sig_bit.alpha = 8; sig_bit.alpha = 8;
type = PNG_COLOR_TYPE_RGB_ALPHA; type = PNG_COLOR_TYPE_RGB_ALPHA;
} else { } else {
sig_bit.alpha = 0; sig_bit.alpha = 0;
type = PNG_COLOR_TYPE_RGB; type = PNG_COLOR_TYPE_RGB;
} }
sig_bit.red = sig_bit.green = sig_bit.blue = 8; sig_bit.red = sig_bit.green = sig_bit.blue = 8;
png_set_IHDR(png_ptr, info_ptr, w, h, 8, type, PNG_INTERLACE_NONE, png_set_IHDR(png_ptr, info_ptr, w, h, 8, type, PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
png_set_sBIT(png_ptr, info_ptr, &sig_bit); png_set_sBIT(png_ptr, info_ptr, &sig_bit);
png_write_info(png_ptr, info_ptr); png_write_info(png_ptr, info_ptr);
png_set_shift(png_ptr, &sig_bit); png_set_shift(png_ptr, &sig_bit);
png_set_packing(png_ptr); png_set_packing(png_ptr);
data = pixbuf->art_pixbuf->pixels; data = pixbuf->art_pixbuf->pixels;
row_ptr = g_new(png_byte *, h); row_ptr = g_new(png_byte *, h);
for (y = 0; y < h; y++) for (y = 0; y < h; y++)
row_ptr[y] = data + y * pixbuf->art_pixbuf->rowstride; row_ptr[y] = data + y * pixbuf->art_pixbuf->rowstride;
#if 0 #if 0
{ {
if (pixbuf->art_pixbuf->has_alpha) if (pixbuf->art_pixbuf->has_alpha)
row_ptr[y] = data + (w * y * 4); row_ptr[y] = data + (w * y * 4);
else else
row_ptr[y] = data + (w * y * 3); row_ptr[y] = data + (w * y * 3);
} }
#endif #endif
png_write_image(png_ptr, row_ptr); png_write_image(png_ptr, row_ptr);
g_free (row_ptr); g_free (row_ptr);
png_write_end(png_ptr, info_ptr); png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, (png_infopp) NULL); png_destroy_write_struct(&png_ptr, (png_infopp) NULL);
return TRUE; return TRUE;
} }

View File

@ -1,5 +1,5 @@
/* /*
* io-tiff.c: GdkPixBuf I/O for TIFF files. * io-tiff.c: GdkPixbuf I/O for TIFF files.
* Copyright (C) 1999 Mark Crichton * Copyright (C) 1999 Mark Crichton
* Author: Mark Crichton <crichton@gimp.org> * Author: Mark Crichton <crichton@gimp.org>
* *
@ -30,68 +30,69 @@
#include "gdk-pixbuf.h" #include "gdk-pixbuf.h"
/*#include "gdk-pixbuf-io.h" */ /*#include "gdk-pixbuf-io.h" */
GdkPixBuf *image_load(FILE * f) GdkPixbuf *
image_load (FILE *f)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
TIFF *tiff; TIFF *tiff;
art_u8 *pixels, *tmppix; art_u8 *pixels, *tmppix;
gint w, h, x, y, num_pixs, fd; gint w, h, x, y, num_pixs, fd;
uint32 *rast, *tmp_rast; uint32 *rast, *tmp_rast;
g_return_val_if_fail(f != NULL, NULL); g_return_val_if_fail(f != NULL, NULL);
fd = fileno(f); fd = fileno(f);
tiff = TIFFFdOpen(fd, "libpixbuf-tiff", "r"); tiff = TIFFFdOpen(fd, "libpixbuf-tiff", "r");
if (!tiff) if (!tiff)
return NULL; return NULL;
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &w);
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h); TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &h);
num_pixs = w * h; num_pixs = w * h;
/* Yes, it needs to be _TIFFMalloc... */ /* Yes, it needs to be _TIFFMalloc... */
rast = (uint32 *) _TIFFmalloc(num_pixs * sizeof(uint32)); rast = (uint32 *) _TIFFmalloc(num_pixs * sizeof(uint32));
if (!rast) { if (!rast) {
TIFFClose(tiff);
return NULL;
}
if (TIFFReadRGBAImage(tiff, w, h, rast, 0)) {
pixels = art_alloc(num_pixs * 4);
if (!pixels) {
_TIFFfree(rast);
TIFFClose(tiff);
return NULL;
}
tmppix = pixels;
for (y = 0; y < h; y++) {
/* Unexplainable...are tiffs backwards? */
/* Also looking at the GIMP plugin, this
* whole reading thing can be a bit more
* robust.
*/
tmp_rast = rast + ((h - y - 1) * w);
for (x = 0; x < w; x++) {
tmppix[0] = TIFFGetR(*tmp_rast);
tmppix[1] = TIFFGetG(*tmp_rast);
tmppix[2] = TIFFGetB(*tmp_rast);
tmppix[3] = TIFFGetA(*tmp_rast);
tmp_rast++;
tmppix += 4;
}
}
}
_TIFFfree(rast);
TIFFClose(tiff); TIFFClose(tiff);
return NULL;
}
if (TIFFReadRGBAImage(tiff, w, h, rast, 0)) { pixbuf = gdk_pixbuf_new (art_pixbuf_new_rgba (pixels, w, h, (w * 4)),
pixels = art_alloc(num_pixs * 4); NULL);
if (!pixels) {
_TIFFfree(rast);
TIFFClose(tiff);
return NULL;
}
tmppix = pixels;
for (y = 0; y < h; y++) { if (!pixbuf)
/* Unexplainable...are tiffs backwards? */ art_free (pixels);
/* Also looking at the GIMP plugin, this
* whole reading thing can be a bit more
* robust.
*/
tmp_rast = rast + ((h - y - 1) * w);
for (x = 0; x < w; x++) {
tmppix[0] = TIFFGetR(*tmp_rast);
tmppix[1] = TIFFGetG(*tmp_rast);
tmppix[2] = TIFFGetB(*tmp_rast);
tmppix[3] = TIFFGetA(*tmp_rast);
tmp_rast++;
tmppix += 4;
}
}
}
_TIFFfree(rast);
TIFFClose(tiff);
pixbuf = gdk_pixbuf_new (art_pixbuf_new_rgba (pixels, w, h, (w * 4)), return pixbuf;
NULL);
if (!pixbuf)
art_free (pixels);
return pixbuf;
} }

View File

@ -1,5 +1,5 @@
/* /*
* io-xpm.c: GdkPixBuf I/O for XPM files. * io-xpm.c: GdkPixbuf I/O for XPM files.
* Copyright (C) 1999 Mark Crichton * Copyright (C) 1999 Mark Crichton
* Author: Mark Crichton <crichton@gimp.org> * Author: Mark Crichton <crichton@gimp.org>
* *
@ -38,399 +38,394 @@
*/ */
enum buf_op { enum buf_op {
op_header, op_header,
op_cmap, op_cmap,
op_body op_body
}; };
typedef struct { typedef struct {
gchar *color_string; gchar *color_string;
GdkColor color; GdkColor color;
gint transparent; gint transparent;
} _XPMColor; } _XPMColor;
struct file_handle { struct file_handle {
FILE *infile; FILE *infile;
gchar *buffer; gchar *buffer;
guint buffer_size; guint buffer_size;
} file_handle; } file_handle;
struct mem_handle { struct mem_handle {
gchar **data; gchar **data;
int offset; int offset;
} mem_handle; } mem_handle;
static gint static gint
xpm_seek_string(FILE * infile, xpm_seek_string(FILE *infile, const gchar *str, gint skip_comments)
const gchar * str,
gint skip_comments)
{ {
char instr[1024]; char instr[1024];
while (!feof(infile)) { while (!feof(infile)) {
fscanf(infile, "%1023s", instr);
if (skip_comments == TRUE && strcmp(instr, "/*") == 0) {
fscanf(infile, "%1023s", instr);
while (!feof(infile) && strcmp(instr, "*/") != 0)
fscanf(infile, "%1023s", instr); fscanf(infile, "%1023s", instr);
fscanf(infile, "%1023s", instr); if (skip_comments == TRUE && strcmp(instr, "/*") == 0) {
} fscanf(infile, "%1023s", instr);
if (strcmp(instr, str) == 0) while (!feof(infile) && strcmp(instr, "*/") != 0)
return TRUE; fscanf(infile, "%1023s", instr);
} fscanf(infile, "%1023s", instr);
return FALSE;
}
static gint
xpm_seek_char(FILE * infile,
gchar c)
{
gint b, oldb;
while ((b = getc(infile)) != EOF) {
if (c != b && b == '/') {
b = getc(infile);
if (b == EOF)
return FALSE;
else if (b == '*') { /* we have a comment */
b = -1;
do {
oldb = b;
b = getc(infile);
if (b == EOF)
return FALSE;
} }
while (!(oldb == '*' && b == '/')); if (strcmp(instr, str) == 0)
} return TRUE;
} else if (c == b) }
return TRUE;
} return FALSE;
return FALSE;
} }
static gint static gint
xpm_read_string(FILE * infile, xpm_seek_char(FILE *infile, gchar c)
gchar ** buffer,
guint * buffer_size)
{ {
gint c; gint b, oldb;
guint cnt = 0, bufsiz, ret = FALSE;
gchar *buf;
buf = *buffer; while ((b = getc(infile)) != EOF) {
bufsiz = *buffer_size; if (c != b && b == '/') {
if (buf == NULL) { b = getc(infile);
bufsiz = 10 * sizeof(gchar); if (b == EOF)
buf = g_new(gchar, bufsiz); return FALSE;
} else if (b == '*') { /* we have a comment */
do b = -1;
c = getc(infile); do {
while (c != EOF && c != '"'); oldb = b;
b = getc(infile);
if (b == EOF)
return FALSE;
}
while (!(oldb == '*' && b == '/'));
}
} else if (c == b)
return TRUE;
}
return FALSE;
}
if (c != '"') static gint
goto out; xpm_read_string(FILE *infile, gchar **buffer, guint *buffer_size)
{
gint c;
guint cnt = 0, bufsiz, ret = FALSE;
gchar *buf;
while ((c = getc(infile)) != EOF) { buf = *buffer;
if (cnt == bufsiz) { bufsiz = *buffer_size;
guint new_size = bufsiz * 2; if (buf == NULL) {
if (new_size > bufsiz) bufsiz = 10 * sizeof(gchar);
bufsiz = new_size; buf = g_new(gchar, bufsiz);
else }
do {
c = getc(infile);
} while (c != EOF && c != '"');
if (c != '"')
goto out; goto out;
buf = (gchar *) g_realloc(buf, bufsiz); while ((c = getc(infile)) != EOF) {
buf[bufsiz - 1] = '\0'; if (cnt == bufsiz) {
} guint new_size = bufsiz * 2;
if (c != '"') if (new_size > bufsiz)
buf[cnt++] = c; bufsiz = new_size;
else { else
buf[cnt] = 0; goto out;
ret = TRUE;
break;
}
}
out: buf = (gchar *) g_realloc(buf, bufsiz);
buf[bufsiz - 1] = '\0'; /* ensure null termination for errors */ buf[bufsiz - 1] = '\0';
*buffer = buf; }
*buffer_size = bufsiz; if (c != '"')
return ret; buf[cnt++] = c;
else {
buf[cnt] = 0;
ret = TRUE;
break;
}
}
out:
buf[bufsiz - 1] = '\0'; /* ensure null termination for errors */
*buffer = buf;
*buffer_size = bufsiz;
return ret;
} }
static gchar * static gchar *
xpm_skip_whitespaces(gchar * buffer) xpm_skip_whitespaces(gchar *buffer)
{ {
gint32 index = 0; gint32 index = 0;
while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09)) while (buffer[index] != 0 && (buffer[index] == 0x20 || buffer[index] == 0x09))
index++; index++;
return &buffer[index]; return &buffer[index];
} }
static gchar * static gchar *
xpm_skip_string(gchar * buffer) xpm_skip_string(gchar *buffer)
{ {
gint32 index = 0; gint32 index = 0;
while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09) while (buffer[index] != 0 && buffer[index] != 0x20 && buffer[index] != 0x09)
index++; index++;
return &buffer[index]; return &buffer[index];
} }
/* Xlib crashed once at a color name lengths around 125 */ /* Xlib crashed once at a color name lengths around 125 */
#define MAX_COLOR_LEN 120 #define MAX_COLOR_LEN 120
static gchar * static gchar *
xpm_extract_color(gchar * buffer) xpm_extract_color(gchar *buffer)
{ {
gint counter, numnames; gint counter, numnames;
gchar *ptr = NULL, ch, temp[128]; gchar *ptr = NULL, ch, temp[128];
gchar color[MAX_COLOR_LEN], *retcol; gchar color[MAX_COLOR_LEN], *retcol;
gint space; gint space;
counter = 0; counter = 0;
while (ptr == NULL) { while (ptr == NULL) {
if (buffer[counter] == 'c') { if (buffer[counter] == 'c') {
ch = buffer[counter + 1]; ch = buffer[counter + 1];
if (ch == 0x20 || ch == 0x09) if (ch == 0x20 || ch == 0x09)
ptr = &buffer[counter + 1]; ptr = &buffer[counter + 1];
} else if (buffer[counter] == 0) } else if (buffer[counter] == 0)
return NULL; return NULL;
counter++; counter++;
}
ptr = xpm_skip_whitespaces(ptr);
if (ptr[0] == 0)
return NULL;
else if (ptr[0] == '#') {
counter = 1;
while (ptr[counter] != 0 &&
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
counter++;
retcol = g_new(gchar, counter + 1);
strncpy(retcol, ptr, counter);
retcol[counter] = 0;
return retcol;
}
color[0] = 0;
numnames = 0;
space = MAX_COLOR_LEN - 1;
while (space > 0) {
sscanf(ptr, "%127s", temp);
if (((gint) ptr[0] == 0) ||
(strcmp("s", temp) == 0) || (strcmp("m", temp) == 0) ||
(strcmp("g", temp) == 0) || (strcmp("g4", temp) == 0)) {
break;
} else {
if (numnames > 0) {
space -= 1;
strcat(color, " ");
}
strncat(color, temp, space);
space -= MIN(space, strlen(temp));
ptr = xpm_skip_string(ptr);
ptr = xpm_skip_whitespaces(ptr);
numnames++;
} }
} ptr = xpm_skip_whitespaces(ptr);
retcol = g_strdup(color); if (ptr[0] == 0)
return retcol; return NULL;
else if (ptr[0] == '#') {
counter = 1;
while (ptr[counter] != 0 &&
((ptr[counter] >= '0' && ptr[counter] <= '9') ||
(ptr[counter] >= 'a' && ptr[counter] <= 'f') ||
(ptr[counter] >= 'A' && ptr[counter] <= 'F')))
counter++;
retcol = g_new(gchar, counter + 1);
strncpy(retcol, ptr, counter);
retcol[counter] = 0;
return retcol;
}
color[0] = 0;
numnames = 0;
space = MAX_COLOR_LEN - 1;
while (space > 0) {
sscanf(ptr, "%127s", temp);
if (((gint) ptr[0] == 0) ||
(strcmp("s", temp) == 0) || (strcmp("m", temp) == 0) ||
(strcmp("g", temp) == 0) || (strcmp("g4", temp) == 0)) {
break;
} else {
if (numnames > 0) {
space -= 1;
strcat(color, " ");
}
strncat(color, temp, space);
space -= MIN(space, strlen(temp));
ptr = xpm_skip_string(ptr);
ptr = xpm_skip_whitespaces(ptr);
numnames++;
}
}
retcol = g_strdup(color);
return retcol;
} }
/* (almost) direct copy from gdkpixmap.c... loads an XPM from a file */ /* (almost) direct copy from gdkpixmap.c... loads an XPM from a file */
static gchar * static gchar *
file_buffer(enum buf_op op, gpointer handle) file_buffer(enum buf_op op, gpointer handle)
{ {
struct file_handle *h = handle; struct file_handle *h = handle;
switch (op) { switch (op) {
case op_header: case op_header:
if (xpm_seek_string(h->infile, "XPM", FALSE) != TRUE) if (xpm_seek_string(h->infile, "XPM", FALSE) != TRUE)
break; break;
if (xpm_seek_char(h->infile, '{') != TRUE) if (xpm_seek_char(h->infile, '{') != TRUE)
break; break;
/* Fall through to the next xpm_seek_char. */ /* Fall through to the next xpm_seek_char. */
case op_cmap: case op_cmap:
xpm_seek_char(h->infile, '"'); xpm_seek_char(h->infile, '"');
fseek(h->infile, -1, SEEK_CUR); fseek(h->infile, -1, SEEK_CUR);
/* Fall through to the xpm_read_string. */ /* Fall through to the xpm_read_string. */
case op_body: case op_body:
xpm_read_string(h->infile, &h->buffer, &h->buffer_size); xpm_read_string(h->infile, &h->buffer, &h->buffer_size);
return h->buffer; return h->buffer;
} }
return 0; return 0;
} }
/* This reads from memory */ /* This reads from memory */
static gchar * static gchar *
mem_buffer(enum buf_op op, gpointer handle) mem_buffer(enum buf_op op, gpointer handle)
{ {
struct mem_handle *h = handle; struct mem_handle *h = handle;
switch (op) { switch (op) {
case op_header: case op_header:
case op_cmap: case op_cmap:
case op_body: case op_body:
if (h->data[h->offset]) if (h->data[h->offset])
return h->data[h->offset++]; return h->data[h->offset++];
} }
return NULL; return NULL;
} }
/* This function does all the work. */ /* This function does all the work. */
static GdkPixBuf * static GdkPixbuf *
_pixbuf_create_from_xpm(gchar * (*get_buf) (enum buf_op op, gpointer handle), _pixbuf_create_from_xpm(gchar * (*get_buf) (enum buf_op op, gpointer handle), gpointer handle)
gpointer handle)
{ {
gint w, h, n_col, cpp; gint w, h, n_col, cpp;
gint cnt, xcnt, ycnt, wbytes, n, ns; gint cnt, xcnt, ycnt, wbytes, n, ns;
gint is_trans = FALSE; gint is_trans = FALSE;
gchar *buffer, *name_buf; gchar *buffer, *name_buf;
gchar pixel_str[32]; gchar pixel_str[32];
GHashTable *color_hash; GHashTable *color_hash;
_XPMColor *colors, *color, *fallbackcolor; _XPMColor *colors, *color, *fallbackcolor;
art_u8 *pixels, *pixtmp; art_u8 *pixels, *pixtmp;
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
ArtPixBuf *art_pixbuf; ArtPixBuf *art_pixbuf;
buffer = (*get_buf) (op_header, handle); buffer = (*get_buf) (op_header, handle);
if (!buffer) {
g_warning("No XPM header found");
return NULL;
}
sscanf(buffer, "%d %d %d %d", &w, &h, &n_col, &cpp);
if (cpp >= 32) {
g_warning("XPM has more than 31 chars per pixel.");
return NULL;
}
/* The hash is used for fast lookups of color from chars */
color_hash = g_hash_table_new(g_str_hash, g_str_equal);
name_buf = g_new(gchar, n_col * (cpp + 1));
colors = g_new(_XPMColor, n_col);
for (cnt = 0; cnt < n_col; cnt++) {
gchar *color_name;
buffer = (*get_buf) (op_cmap, handle);
if (!buffer) { if (!buffer) {
g_warning("Can't load XPM colormap"); g_warning("No XPM header found");
g_hash_table_destroy(color_hash); return NULL;
g_free(name_buf);
g_free(colors);
return NULL;
} }
color = &colors[cnt]; sscanf(buffer, "%d %d %d %d", &w, &h, &n_col, &cpp);
color->color_string = &name_buf[cnt * (cpp + 1)]; if (cpp >= 32) {
strncpy(color->color_string, buffer, cpp); g_warning("XPM has more than 31 chars per pixel.");
color->color_string[cpp] = 0; return NULL;
buffer += strlen(color->color_string); }
color->transparent = FALSE; /* The hash is used for fast lookups of color from chars */
color_hash = g_hash_table_new(g_str_hash, g_str_equal);
color_name = xpm_extract_color(buffer); name_buf = g_new(gchar, n_col * (cpp + 1));
colors = g_new(_XPMColor, n_col);
if ((color_name == NULL) || (g_strcasecmp(color_name, "None") == 0) for (cnt = 0; cnt < n_col; cnt++) {
|| (gdk_color_parse(color_name, &color->color) == FALSE)) { gchar *color_name;
color->transparent = TRUE;
is_trans = TRUE; buffer = (*get_buf) (op_cmap, handle);
if (!buffer) {
g_warning("Can't load XPM colormap");
g_hash_table_destroy(color_hash);
g_free(name_buf);
g_free(colors);
return NULL;
}
color = &colors[cnt];
color->color_string = &name_buf[cnt * (cpp + 1)];
strncpy(color->color_string, buffer, cpp);
color->color_string[cpp] = 0;
buffer += strlen(color->color_string);
color->transparent = FALSE;
color_name = xpm_extract_color(buffer);
if ((color_name == NULL) || (g_strcasecmp(color_name, "None") == 0)
|| (gdk_color_parse(color_name, &color->color) == FALSE)) {
color->transparent = TRUE;
is_trans = TRUE;
}
g_free(color_name);
g_hash_table_insert(color_hash, color->color_string, color);
if (cnt == 0)
fallbackcolor = color;
} }
g_free(color_name); if (is_trans)
g_hash_table_insert(color_hash, color->color_string, color); pixels = art_alloc(w * h * 4);
else
pixels = art_alloc(w * h * 3);
if (cnt == 0) if (!pixels) {
fallbackcolor = color; g_warning("XPM: Cannot alloc ArtBuf");
} g_hash_table_destroy(color_hash);
g_free(colors);
g_free(name_buf);
return NULL;
}
wbytes = w * cpp;
pixtmp = pixels;
if (is_trans) for (ycnt = 0; ycnt < h; ycnt++) {
pixels = art_alloc(w * h * 4); buffer = (*get_buf) (op_body, handle);
else if ((!buffer) || (strlen(buffer) < wbytes))
pixels = art_alloc(w * h * 3); continue;
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) {
strncpy(pixel_str, &buffer[n], cpp);
pixel_str[cpp] = 0;
ns = 0;
if (!pixels) { color = g_hash_table_lookup(color_hash, pixel_str);
g_warning("XPM: Cannot alloc ArtBuf");
/* Bad XPM...punt */
if (!color)
color = fallbackcolor;
*pixtmp++ = (color->color.red)>>8;
*pixtmp++ = (color->color.green)>>8;
*pixtmp++ = (color->color.blue)>>8;
if ((is_trans) && (color->transparent)) {
*pixtmp++ = 0;
} else if (is_trans) {
*pixtmp++ = 0xFF;
}
}
}
g_hash_table_destroy(color_hash); g_hash_table_destroy(color_hash);
g_free(colors); g_free(colors);
g_free(name_buf); g_free(name_buf);
return NULL;
}
wbytes = w * cpp;
pixtmp = pixels;
for (ycnt = 0; ycnt < h; ycnt++) { /* Ok, now stuff the GdkPixbuf with goodies */
buffer = (*get_buf) (op_body, handle);
if ((!buffer) || (strlen(buffer) < wbytes))
continue;
for (n = 0, cnt = 0, xcnt = 0; n < wbytes; n += cpp, xcnt++) {
strncpy(pixel_str, &buffer[n], cpp);
pixel_str[cpp] = 0;
ns = 0;
color = g_hash_table_lookup(color_hash, pixel_str); if (is_trans)
art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
/* Bad XPM...punt */ pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
if (!color)
color = fallbackcolor;
*pixtmp++ = (color->color.red)>>8; if (!pixbuf)
*pixtmp++ = (color->color.green)>>8; art_free(pixels);
*pixtmp++ = (color->color.blue)>>8;
if ((is_trans) && (color->transparent)) { return pixbuf;
*pixtmp++ = 0;
} else if (is_trans) {
*pixtmp++ = 0xFF;
}
}
}
g_hash_table_destroy(color_hash);
g_free(colors);
g_free(name_buf);
/* Ok, now stuff the GdkPixBuf with goodies */
if (is_trans)
art_pixbuf = art_pixbuf_new_rgba(pixels, w, h, (w * 4));
else
art_pixbuf = art_pixbuf_new_rgb(pixels, w, h, (w * 3));
pixbuf = gdk_pixbuf_new (art_pixbuf, NULL);
if (!pixbuf)
art_free(pixels);
return pixbuf;
} }
/* Shared library entry point for file loading */ /* Shared library entry point for file loading */
GdkPixBuf *image_load(FILE * f) GdkPixbuf *
image_load (FILE *f)
{ {
GdkPixBuf *pixbuf; GdkPixbuf *pixbuf;
struct file_handle h; struct file_handle h;
g_return_val_if_fail(f != NULL, NULL); g_return_val_if_fail(f != NULL, NULL);
memset(&h, 0, sizeof(h)); memset(&h, 0, sizeof(h));
h.infile = f; h.infile = f;
pixbuf = _pixbuf_create_from_xpm(file_buffer, &h); pixbuf = _pixbuf_create_from_xpm(file_buffer, &h);
g_free(h.buffer); g_free(h.buffer);
return pixbuf; return pixbuf;
} }
image_save() image_save()

View File

@ -1,18 +0,0 @@
#ifndef _GDK_PIXBUF_H_
#define _GDK_PIXBUF_H_
#include <libart_lgpl/art_pixbuf.h>
typedef struct {
int ref_count;
ArtPixBuf *pixbuf;
void (*unref_func)(void *gdkpixbuf);
} GdkPixBuf;
GdkPixBuf *gdk_pixbuf_load_image (const char *file);
void gdk_pixbuf_save_image (const char *format_id, const char *file, ...);
void gdk_pixbuf_ref (GdkPixBuf *pixbuf);
void gdk_pixbuf_unref (GdkPixBuf *pixbuf);
GdkPixBuf gdk_pixbuf_duplicate (GdkPixBuf *pixbuf);
#endif /* _GDK_PIXBUF_H_ */

View File

@ -1,5 +1,5 @@
/* /*
* Creates an GdkPixBuf from a Drawable * Creates an GdkPixbuf from a Drawable
* *
* Author: * Author:
* Cody Russell <bratsche@dfw.net> * Cody Russell <bratsche@dfw.net>
@ -14,10 +14,8 @@
/* private function */ /* private function */
static GdkPixBuf * static GdkPixbuf *
gdk_pixbuf_from_drawable_core (GdkWindow *window, gdk_pixbuf_from_drawable_core (GdkWindow *window, gint x, gint y, gint width, gint height,
gint x, gint y,
gint width, gint height,
gint with_alpha) gint with_alpha)
{ {
GdkImage *image; GdkImage *image;
@ -41,26 +39,20 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
&window_width, &window_height, NULL); &window_width, &window_height, NULL);
gdk_window_get_origin(window, &window_x, &window_y); gdk_window_get_origin(window, &window_x, &window_y);
if(window_x < 0) if(window_x < 0) {
{
x = ABS(window_x); x = ABS(window_x);
width = window_width - x; width = window_width - x;
} } else {
else
{
width = CLAMP(window_x + window_width, window_x, width = CLAMP(window_x + window_width, window_x,
screen_width) - window_x; screen_width) - window_x;
} }
if(window_y < 0) if(window_y < 0) {
{
y = ABS(window_y); y = ABS(window_y);
height = window_height - y; height = window_height - y;
} } else {
else
{
height = CLAMP(window_y + window_height, window_y, height = CLAMP(window_y + window_height, window_y,
screen_height) - window_y; screen_height) - window_y;
} }
image = gdk_image_get (window, x, y, width, height); image = gdk_image_get (window, x, y, width, height);
@ -72,8 +64,7 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
buff = art_alloc (rowstride * height); buff = art_alloc (rowstride * height);
pixels = buff; pixels = buff;
switch (image->depth) switch (image->depth) {
{
case 0: case 0:
case 1: case 1:
case 2: case 2:
@ -83,10 +74,8 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
case 6: case 6:
case 7: case 7:
case 8: case 8:
for (yy = 0; yy < height; yy++) for (yy = 0; yy < height; yy++) {
{ for (xx = 0; xx < width; xx++) {
for (xx = 0; xx < width; xx++)
{
pixel = gdk_image_get_pixel (image, xx, yy); pixel = gdk_image_get_pixel (image, xx, yy);
pixels[0] = colormap->colors[pixel].red; pixels[0] = colormap->colors[pixel].red;
pixels[1] = colormap->colors[pixel].green; pixels[1] = colormap->colors[pixel].green;
@ -94,17 +83,15 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
if (with_alpha) if (with_alpha)
pixels[3] = 0; pixels[3] = 0;
pixels += fatness; pixels += fatness;
} }
} }
break; break;
case 16: case 16:
case 15: case 15:
for (yy = 0; yy < height; yy++) for (yy = 0; yy < height; yy++) {
{ for (xx = 0; xx < width; xx++) {
for (xx = 0; xx < width; xx++)
{
pixel = gdk_image_get_pixel (image, xx, yy); pixel = gdk_image_get_pixel (image, xx, yy);
r = (pixel >> 8) & 0xf8; r = (pixel >> 8) & 0xf8;
g = (pixel >> 3) & 0xfc; g = (pixel >> 3) & 0xfc;
@ -121,10 +108,8 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
case 24: case 24:
case 32: case 32:
for (yy = 0; yy < height; yy++) for (yy = 0; yy < height; yy++) {
{ for (xx = 0; xx < width; xx++) {
for (xx = 0; xx < width; xx++)
{
pixel = gdk_image_get_pixel (image, xx, yy); pixel = gdk_image_get_pixel (image, xx, yy);
r = (pixel >> 16) & 0xff; r = (pixel >> 16) & 0xff;
g = (pixel >> 8) & 0xff; g = (pixel >> 8) & 0xff;
@ -151,18 +136,14 @@ gdk_pixbuf_from_drawable_core (GdkWindow *window,
/* Public functions */ /* Public functions */
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_rgb_from_drawable (GdkWindow *window, gdk_pixbuf_rgb_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height)
gint x, gint y,
gint width, gint height)
{ {
return gdk_pixbuf_from_drawable_core (window, x, y, width, height, 0); return gdk_pixbuf_from_drawable_core (window, x, y, width, height, 0);
} }
GdkPixBuf * GdkPixbuf *
gdk_pixbuf_rgba_from_drawable (GdkWindow *window, gdk_pixbuf_rgba_from_drawable (GdkWindow *window, gint x, gint y, gint width, gint height)
gint x, gint y,
gint width, gint height)
{ {
return gdk_pixbuf_from_drawable_core (window, x, y, width, height, 1); return gdk_pixbuf_from_drawable_core (window, x, y, width, height, 1);
} }