LECTURE 22 ¥Õ¥§¡¼¥É¥¤¥ó¡¿¥Õ¥§¡¼¥É¥¢¥¦¥È

¡û ¤Ï¤¸¤á¤Ë

º£²ó¤Ï¡¢Imlib ¤ÇÆɤ߹þ¤ó¤À²èÁü¥Ç¡¼¥¿¤ò»È¤Ã¤¿¥Õ¥§¡¼¥É¥¤¥ó¡¿¥Õ¥§¡¼¥É¥¢¥¦¥È¤ò¼ÂÁõ¤·¤Æ¤ß¤Þ¤¹¡£

¤¿¤À¤·¥¢¥ë¥´¥ê¥º¥à¤ÎÀâÌÀ¤È´Êñ¤Ë¼Â¹Ô·ë²Ì¤òÆÀ¤ë¤³¤È¤òÌÜŪ¤È¤·¤Þ¤¹¤Î¤Ç¡¢Shared Memory Extension (XImage ¤ä Pixmap ¤ò¥µ¡¼¥Ð¡¿¥¯¥é¥¤¥¢¥ó¥È´Ö¤Î¶¦Í­¥á¥â¥ê¤ËÃÖ¤±¤ëÍͤˤ¹¤ë¡£¤³¤ì¤Ë¤è¤êÂçÍÆÎ̲èÁü¥Ç¡¼¥¿¤òÄÌ¿®Ï©¤Ë¾è¤»¤ëɬÍפ¬Ìµ¤¯¤Ê¤ë¤¿¤á¡¢¹â®²½¤¬¿Þ¤ì¤ë¤È¤¤¤¦³ÈÄ¥¡ËÅù¤Î¹â®²½¤Ï¹Íθ¤·¤Æ¤¤¤Þ¤»¤ó¡£¤½¤Î¤¿¤áÂ礭¤Ê²èÁü¤Ç¤ÏÈó¾ï¤Ë»þ´Ö¤¬¤«¤«¤Ã¤Æ¤·¤Þ¤¦¾ì¹ç¤¬¤¢¤ê¤Þ¤¹¤¬¡¢¤´Î»¾µ¤¯¤À¤µ¤¤¡£

¡û ¥Õ¥§¡¼¥É¥¤¥ó½èÍý

¥Õ¥§¡¼¥É¥¤¥ó¤Ï¡¢¿¿¤Ã°Å¤Ê¾õÂÖ¤«¤é¾¯¤·¤Å¤Ä²èÁü¤òɽ¼¨¤·¤Æ¤¤¤¯½èÍý¤Ç¤¹¡£¤³¤ì¤Ï¡¢¥Ô¥¯¥»¥ë¤ÎÃͤ¬½é´ü¾õÂÖ¤Ç¤Ï RGB Á´¤Æ 0¡Ê¹õ¿§¡Ë¤Ç¤¢¤ê¡¢ºÇ½ªÅª¤Ë¤Ïɽ¼¨¤·¤¿¤¤²èÁü¤ÎÃͤˤʤì¤ÐÎɤ¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£

¤è¤Ã¤Æ

ÊÑ´¹¸å¤ÎÃÍ = ratio * ÊÑ´¹Á°¤ÎÃÍ
¢¨(0.0 <= ratio <= 1.0)

¤Ç¤¢¤ê¡¢ratio ¤ò 0.0 ¤«¤é 1.0 ¤Þ¤Ç¾¯¤·¤Å¤ÄÊѲ½¤µ¤»¤Æ¤¤¤±¤ÐÎɤ¤¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¡û ¥Õ¥§¡¼¥É¥¢¥¦¥È½èÍý

¥Õ¥§¡¼¥É¥¢¥¦¥È¤Ï¡¢²èÁü¤òɽ¼¨¤·¤Æ¤¤¤ë¾õÂÖ¤«¤é¾¯¤·¤Å¤Ä°Å¤¯¤·¤Æ¤¤¤­¡¢ºÇ½ªÅª¤Ë¿¿¤Ã°Å¤Ê¾õÂ֤ˤ¹¤ë½èÍý¤Ç¤¹¡£¤³¤ì¤Ï¡¢¥Ô¥¯¥»¥ë¤ÎÃͤ¬½é´ü¾õÂ֤ǤϲèÁü¤ÎÃͤǤ¢¤ê¡¢ºÇ½ªÅª¤Ë¤Ï RGB Á´¤Æ 0¡Ê¹õ¿§¡Ë¤Ë¤Ê¤ì¤ÐÎɤ¤¤³¤È¤ò°ÕÌ£¤·¤Þ¤¹¡£

¤è¤Ã¤Æ

ÊÑ´¹¸å¤ÎÃÍ = ratio * ÊÑ´¹Á°¤ÎÃÍ
¢¨(0.0 <= ratio <= 1.0)

¤Ç¤¢¤ê¡¢ratio ¤ò 1.0 ¤«¤é 0.0 ¤Þ¤Ç¾¯¤·¤Å¤ÄÊѲ½¤µ¤»¤Æ¤¤¤±¤ÐÎɤ¤¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à

¥Õ¥§¡¼¥É¥¤¥ó¡¿¥Õ¥§¡¼¥É¥¢¥¦¥È¤ò¼ÂÁõ¤·¤¿¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à fade.c ¤Ç¤¹¡£¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤éÁ´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

Á°²ó¤ÈƱ¤¸¤¯¡¢-lImlib ¥ª¥×¥·¥ç¥ó¤ò»ØÄꤷ¤Æ¥³¥ó¥Ñ¥¤¥ë¤·¤Æ¤¯¤À¤µ¤¤¡£

¥³¥ó¥Ñ¥¤¥ë¤ò½ª¤¨¤¿¤é¡¢²èÁü¥Õ¥¡¥¤¥ë̾¤ò°ú¿ô¤ËÍ¿¤¨¤Æ¼Â¹Ô¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£²èÁü¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£¾å¤Î¥«¡¼¥½¥ë¥­¡¼¤ò²¡¤¹¤È¥Õ¥§¡¼¥É¥¤¥ó¡¢²¼¤ò²¡¤¹¤È¥Õ¥§¡¼¥É¥¢¥¦¥È¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£º¸±¦¤ò²¡¤¹¤È¸µ²èÁü¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£Esc ¥­¡¼¤ò²¡¤¹¤È½ªÎ»¤·¤Þ¤¹¡£

ËÜ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ï¡¢µ¯Æ°»þ¤Ë¸µ²èÁü¤ò¥á¥â¥ê¾å¤ËÊݸ¤·¤Þ¤¹¡£¤½¤Î¤¿¤á¡¢Â礭¤Ê²èÁüÅù¤òɽ¼¨¤¹¤ë¤È·ë¹½¥á¥â¥ê¤ò¾ÃÈñ¤¹¤ë¤È»×¤¤¤Þ¤¹¡£¤Þ¤¿¡¢¥Õ¥§¡¼¥É¥¤¥ó¡¿¥Õ¥§¡¼¥É¥¢¥¦¥È½èÍý¤Ë¤ª¤¤¤Æ¤Ï¹â®²½¤ä¥¿¥¤¥ß¥ó¥°¤ÎƱ´üÅù¤ò¹Íθ¤·¤Æ¤¤¤Þ¤»¤ó¤Î¤Ç¡¢²èÁü¤Î¥µ¥¤¥º¤Ë¤è¤Ã¤Æ½êÍÑ»þ´Ö¤¬°Û¤Ê¤ê¤Þ¤¹¡£¥µ¥¤¥º¤¬Â礭¤¤¾ì¹ç¤Ï¤«¤Ê¤êÃÙ¤¯¤Ê¤ë²ÄǽÀ­¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢¤´Î»¾µ¤¯¤À¤µ¤¤¡£¤Ê¤ª¡¢¥²¡¼¥à¤ä¥¢¥Ë¥á¡¼¥·¥ç¥óÅù¤Ç½èÍý½ªÎ»¤Þ¤Ç¤Î»þ´Ö¤ò°ìÄê¤Ë¤·¤¿¤¤¾ì¹ç¤Ï¡¢1 ¥Õ¥ì¡¼¥àɽ¼¨¤¹¤ëËè¤Ë½êÍÑ»þ´Ö¤ò·×¬¤·¡¢Á᤹¤®¤ì¤ÐÂԤġ¿ÃÙ¤¹¤®¤¿¤é¥Õ¥ì¡¼¥à¤ò¥¹¥­¥Ã¥×¤¹¤ëÅù¤Î¼ÂÁõ¤¬É¬ÍפǤ¹¡£

¤Þ¤¿¡¢¥¤¥Ù¥ó¥È¥ë¡¼¥×Æâ¤Ç¾å²¼¥­¡¼¤ò²¡¤¹¤È¥Õ¥§¡¼¥É¥¤¥ó¡¿¥Õ¥§¡¼¥É¥¢¥¦¥È½èÍý¤ò¼Â¹Ô¤·¤Þ¤¹¤¬¡¢½èÍý¤¬½ª¤ï¤ë¤Þ¤Ç¥¤¥Ù¥ó¥È½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Ê¤¤¤¿¤á¡¢¥¦¥£¥ó¥É¥¦¤¬¸Ç¤Þ¤Ã¤¿Íͤˤʤë¤È»×¤¤¤Þ¤¹¡£¤´Î»¾µ¤¯¤À¤µ¤¤¡£GUI ¤È¤·¤Æ¼ÂÍÑŪ¤Ë¤¹¤ë¤¿¤á¤Ë¤Ï¡¢1 ¥Õ¥ì¡¼¥àɽ¼¨¤¹¤ëËè¤Ë¥¤¥Ù¥ó¥È½èÍý¤ò¹Ô¤¦Åù¤Î¼ÂÁõ¤ò¹Í¤¨¤¿Êý¤¬Îɤ¤¤Ç¤·¤ç¤¦¡£

--- ¥Õ¥§¡¼¥É¥¤¥ó»þ¡ÊÀŻ߲è¤Ç¤¹¤¬µ¤Ê¬¤À¤±¤Ç¤â¡Ä¡Ë ---

¥Õ¥§¡¼¥É¥¤¥ó³«»Ï
¢­
¥Õ¥§¡¼¥É¥¤¥óÃæ´Ö
¢­
¥Õ¥§¡¼¥É¥¤¥ó½ªÎ»

--- ¥Õ¥§¡¼¥É¥¢¥¦¥È»þ¡ÊÀŻ߲è¤Ç¤¹¤¬µ¤Ê¬¤À¤±¤Ç¤â¡Ä¡Ë ---

¥Õ¥§¡¼¥É¥¢¥¦¥È³«»Ï
¢­
¥Õ¥§¡¼¥É¥¢¥¦¥ÈÃæ´Ö
¢­
¥Õ¥§¡¼¥É¥¢¥¦¥È½ªÎ»

¤Ê¤ª¡¢fade_in() ¤ª¤è¤Ó fade_out() ¤Ë¤Ä¤¤¤Æ¡¢1280x1024 ¤Î JPEG ²èÁü¤òÍѤ¤¤Æ¼Â¹Ô¤·¤¿¾ì¹ç¤Ë¤«¤«¤Ã¤¿»þ´Ö¤ò¼«´Ä¶­¤Ç·×¬¤·¤¿·ë²Ì¤ò°Ê²¼¤ËºÜ¤»¤Æ¤ª¤­¤Þ¤¹¡£

PentiumIII 450MHz
memory 512MB
Xeon 3.60GHz
memory 1GB
fade_in() 19933.406 ms 3630.223 ms
fade_out() 19844.507 ms 3671.891 ms

--- fade.c ---

    1	#include <X11/Xlib.h>
    2	#include <X11/keysym.h>
    3	#include <X11/Xutil.h>            /* shape.h ¤ÎÁ°¤ËɬÍ× */
    4	#include <X11/extensions/shape.h> /* Shape Extension    */
    5	#include <Imlib.h>
    6	#include <stdio.h>
    7	#include <string.h>
    8	#include <sys/time.h>
    9	#include <unistd.h>
   10	
   11	static Display* display;
   12	static Window window;
   13	static ImlibData*  imlib_data;
   14	static ImlibImage* imlib_image;
   15	static Pixmap pixmap;
   16	static Pixmap mask;
   17	static unsigned char* original;
   18	static int width;
   19	static int height;
   20	
   21	
   22	static int  save_original( void );
   23	static void disable_resize( void );
   24	static void render( void );
   25	static void update_image( void );
   26	static void show_original( void );
   27	static void fade_in( void );
   28	static void fade_out( void );
   29	
   30	
   31	int
   32	main( int argc, char** argv )
   33	{
   34		int screen;
   35	
   36		if ( argc <= 1 ) {
   37			fprintf( stderr, "²èÁü¥Õ¥¡¥¤¥ë¤ò»ØÄꤷ¤Æ¤¯¤À¤µ¤¤¡£\n" );
   38			exit(1);
   39		}
   40	
   41		display = XOpenDisplay( NULL );
   42		screen  = DefaultScreen( display );
   43	
   44		if ( ( imlib_data = Imlib_init( display ) ) == NULL ) {
   45			fprintf( stderr, "Imlib ¤Î½é´ü²½¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n" );
   46			XCloseDisplay( display );
   47			exit(1);
   48		}
   49	
   50		if ( ( imlib_image = Imlib_load_image( imlib_data, argv[1] ) ) == NULL ) {
   51			fprintf( stderr, "²èÁü¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n" );
   52			XCloseDisplay( display );
   53			exit(1);
   54		}
   55	
   56		width  = imlib_image->rgb_width;
   57		height = imlib_image->rgb_height;
   58	
   59		if ( save_original() != 0 ) {
   60			fprintf( stderr, "¸µ²èÁü¤ÎÊݸ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£\n" );
   61			Imlib_kill_image( imlib_data, imlib_image );
   62			XCloseDisplay( display );
   63			exit(1);
   64		}
   65	
   66		window = XCreateSimpleWindow( 
   67			display, 
   68			DefaultRootWindow( display ),
   69			width,
   70			height,
   71			width,
   72			height,
   73			0,
   74			BlackPixel( display, screen ),
   75			BlackPixel( display, screen ) 
   76			);
   77	
   78		disable_resize();
   79		XSelectInput( display, window, StructureNotifyMask | KeyPressMask );
   80		XMapWindow( display, window );
   81		render();
   82		update_image();
   83	
   84		while ( 1 ) {
   85			int esc_pressed = 0;
   86			XEvent event;
   87			KeySym key_sym;
   88	
   89			XNextEvent( display, &event );
   90	
   91			switch ( event.type ) {
   92				case KeyPress:
   93					XLookupString( &( event.xkey ), 
   94						NULL, 0, &key_sym, NULL );
   95	
   96					switch ( key_sym ) {
   97						case XK_Left:
   98						case XK_Right:
   99							show_original();
  100							break;
  101	
  102						case XK_Up:
  103							fade_in();
  104							break;
  105	
  106						case XK_Down:
  107							fade_out();
  108							break;
  109	
  110						case XK_Escape:
  111							esc_pressed = 1;
  112							break;
  113					}
  114	
  115					break;
  116			}
  117	
  118			if ( esc_pressed ) {
  119				break;
  120			}
  121		}
  122	
  123		Imlib_free_pixmap( imlib_data, pixmap );
  124		Imlib_kill_image( imlib_data, imlib_image );
  125		free( original );
  126		XDestroyWindow( display, window );
  127		XCloseDisplay( display );
  128		return 0;
  129	}
  130	
  131	
  132	static int
  133	save_original( void )
  134	{
  135		int size = width * height * 3;
  136	
  137		if ( ( original = ( unsigned char* )malloc( size ) ) == NULL ) {
  138			return -1;
  139		}
  140	
  141		memcpy( original, imlib_image->rgb_data, size );
  142		return 0;
  143	}
  144	
  145	
  146	static void
  147	disable_resize( void )
  148	{
  149		XSizeHints hints;
  150	
  151		hints.min_width  = width;
  152		hints.min_height = height;
  153		hints.max_width  = width;
  154		hints.max_height = height;
  155		hints.flags = PMinSize | PMaxSize;
  156	
  157		XSetWMNormalHints( display, window, &hints );
  158	}
  159	
  160	
  161	static void
  162	render( void )
  163	{
  164		Imlib_render( imlib_data, imlib_image, width, height );
  165		pixmap = Imlib_move_image( imlib_data, imlib_image );
  166		mask = Imlib_move_mask( imlib_data, imlib_image );
  167	}
  168	
  169	
  170	static void
  171	update_image( void )
  172	{
  173		XSetWindowBackgroundPixmap( display, window, pixmap );
  174		
  175		if ( mask ) {
  176			XShapeCombineMask( display, window, 
  177				ShapeBounding, 0, 0, mask, ShapeSet );
  178		}
  179	
  180		XClearWindow( display, window );
  181		XSync( display, False );
  182	}
  183	
  184	
  185	static void
  186	show_original( void )
  187	{
  188		memcpy( imlib_image->rgb_data, original, width * height * 3 );
  189		Imlib_free_pixmap( imlib_data, pixmap );
  190		Imlib_changed_image( imlib_data, imlib_image );
  191		render();
  192		update_image();
  193	}
  194	
  195	
  196	#define TIMER_DIFF( diff, end, start ) { \
  197		(diff)->tv_usec = (end)->tv_usec - (start)->tv_usec; \
  198		if ( (diff)->tv_usec < 0 ) {\
  199			(diff)->tv_usec += 1000000; \
  200			(diff)->tv_sec = (end)->tv_sec - (start)->tv_sec - 1;\
  201		}\
  202		else {\
  203			(diff)->tv_sec = (end)->tv_sec - (start)->tv_sec;\
  204		}\
  205		if ( (diff)->tv_sec < 0 ) {\
  206			(diff)->tv_sec = (diff)->tv_usec = 0;\
  207		}\
  208	}
  209	
  210	#define MIX_IMAGE( ratio ) { \
  211		int row;   \
  212		int col;   \
  213		int rgb;   \
  214		int index; \
  215	\
  216		for ( row = 0; row < height; row ++ ) { \
  217			for ( col = 0; col < width; col ++ ) { \
  218				for ( rgb = 0; rgb < 3; rgb ++ ) { \
  219					index = ( row * width + col ) * 3 + rgb; \
  220					imlib_image->rgb_data[ index ] = ( unsigned char )\
  221					  ( original[ index ] * ( ratio ) / 100 ); \
  222				} \
  223			} \
  224		} \
  225	\
  226		Imlib_free_pixmap( imlib_data, pixmap ); \
  227		Imlib_changed_image( imlib_data, imlib_image ); \
  228		render(); \
  229		update_image(); \
  230	}
  231	
  232	
  233	static void
  234	fade_in( void )
  235	{
  236		struct timeval start;
  237		struct timeval end;
  238		struct timeval diff;
  239	
  240		int ratio = 0;
  241	
  242		printf( "Fade in..." );
  243		fflush( stdout );
  244		gettimeofday( &start, NULL );
  245	
  246		while ( ratio < 100 ) {
  247			MIX_IMAGE( ratio );
  248			ratio += 2;
  249		}
  250	
  251		gettimeofday( &end, NULL );
  252		TIMER_DIFF( &diff, &end, &start );
  253		printf( "done ( %ld ).\n", diff.tv_sec * 1000000 + diff.tv_usec );
  254		fflush( stdout );
  255	}
  256	
  257	
  258	static void
  259	fade_out( void )
  260	{
  261		struct timeval start;
  262		struct timeval end;
  263		struct timeval diff;
  264	
  265		int ratio = 100;
  266	
  267		printf( "Fade out..." );
  268		fflush( stdout );
  269		gettimeofday( &start, NULL );
  270	
  271		while ( ratio > 0 ) {
  272			MIX_IMAGE( ratio );
  273			ratio -= 2;
  274		}
  275	
  276		gettimeofday( &end, NULL );
  277		TIMER_DIFF( &diff, &end, &start );
  278		printf( "done ( %ld ).\n", diff.tv_sec * 1000000 + diff.tv_usec );
  279		fflush( stdout );
  280	}
  281	
  282	
  283	/* End of fade.c */


¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£Imlib ¤Ë¤è¤ë²èÁüÆɤ߹þ¤ß¡¿É½¼¨¡¢¤½¤Î¾¤¤¤¯¤Ä¤«¤Î½èÍý¤Ë¤Ä¤¤¤Æ¤Ï LECTURE 20 Imlib ¤ò»È¤Ã¤¿²èÁüɽ¼¨ ¤ª¤è¤Ó LECTURE 21 ²èÁü¤Î¥°¥ì¡¼¥¹¥±¡¼¥ë¡¿¥Í¥¬¥Æ¥£¥Ö¡¿¥¨¥Ã¥¸¸¡½Ð½èÍý¤ò´ðËܤȤ·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

  • 31 ¡Á 129 ¹ÔÌÜ ( main() )

    fade.c ¤Î main ´Ø¿ô¤Ç¤¹¡£³Æ½èÍý¤Ë¤Ä¤¤¤Æ°Ê²¼¤ÇÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

    • 59 ¡Á 64 ¹ÔÌÜ

      save_original() ¤È¤¤¤¦¼«ºî´Ø¿ô¤Ç¡¢Imlib ¤ÇÆɤ߹þ¤ó¤À¸µ²èÁü¥Ç¡¼¥¿¤ÎÊݸ¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¸åÄøÀâÌÀ¤·¤Þ¤¹¡£

    • 78 ¹ÔÌÜ

      ´Êñ¤Î¤¿¤á¡¢disable_resize() ¤È¤¤¤¦¼«ºî´Ø¿ô¤Ç¥¦¥£¥ó¥É¥¦¥µ¥¤¥º¤òÊѹ¹¤Ç¤­¤Ê¤¯¤·¤Æ¤¤¤Þ¤¹¡£LECTURE 21 ²èÁü¤Î¥°¥ì¡¼¥¹¥±¡¼¥ë¡¿¥Í¥¬¥Æ¥£¥Ö¡¿¥¨¥Ã¥¸¸¡½Ð½èÍý ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈƱ¤¸¤Ê¤Î¤Ç¡¢¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

    • 97 ¡Á 100 ¹ÔÌÜ

      º¸±¦¤Î¥«¡¼¥½¥ë¥­¡¼¤¬²¡¤µ¤ì¤¿»þ¤Î½èÍý¤Ç¤¹¡£show_original() ¤È¤¤¤¦¼«ºî´Ø¿ô¤Ç¸µ²èÁü¤Îɽ¼¨¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£LECTURE 21 ²èÁü¤Î¥°¥ì¡¼¥¹¥±¡¼¥ë¡¿¥Í¥¬¥Æ¥£¥Ö¡¿¥¨¥Ã¥¸¸¡½Ð½èÍý ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈƱ¤¸¤Ê¤Î¤Ç¡¢¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

    • 102 ¡Á 104 ¹ÔÌÜ

      ¾å¤Î¥«¡¼¥½¥ë¥­¡¼¤¬²¡¤µ¤ì¤¿»þ¤Î½èÍý¤Ç¤¹¡£fade_in() ¤È¤¤¤¦¼«ºî´Ø¿ô¤Ç¥Õ¥§¡¼¥É¥¤¥ó½èÍý¤ò³«»Ï¤·¤Æ¤¤¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¸åÄøÀâÌÀ¤·¤Þ¤¹¡£

    • 106 ¡Á 108 ¹ÔÌÜ

      ²¼¤Î¥«¡¼¥½¥ë¥­¡¼¤¬²¡¤µ¤ì¤¿»þ¤Î½èÍý¤Ç¤¹¡£fade_out() ¤È¤¤¤¦¼«ºî´Ø¿ô¤Ç¥Õ¥§¡¼¥É¥¢¥¦¥È½èÍý¤ò³«»Ï¤·¤Æ¤¤¤Þ¤¹¡£¾Ü¤·¤¯¤Ï¸åÄøÀâÌÀ¤·¤Þ¤¹¡£

    • 123 ¡Á 125 ¹ÔÌÜ

      Imlib_free_pixmap() ¤Ë¤è¤Ã¤Æ Pixmap ¤ò²òÊü¤·¤¿¸å¡¢Imlib_kill_image() ¤ò»È¤Ã¤Æ ImlibImage ¹½Â¤ÂΤò²òÊü¤·¤Æ¤¤¤Þ¤¹¡£¹¹¤Ë¡¢Êݸ¤·¤Æ¤ª¤¤¤¿¸µ²èÁü¥Ç¡¼¥¿¤ò²òÊü¤·¤Æ¤¤¤Þ¤¹¡£

  • 132 ¡Á 143 ¹ÔÌÜ ( save_original() )

    ËÜ´Ø¿ô¤Ç¤Ï¡¢Imlib ÆâÉô¤Ë³ÊǼ¤µ¤ì¤Æ¤¤¤ë¸µ²èÁü¥Ç¡¼¥¿¤ÎÊݸ¤ò¹Ô¤¤¤Þ¤¹¡£¥°¥ì¡¼¥¹¥±¡¼¥ë²èÁü¤Ë´Ø¤¹¤ë½èÍý¤ò¹Ô¤Ã¤Æ¤¤¤Ê¤¤°Ê³°¤ÏLECTURE 21 ²èÁü¤Î¥°¥ì¡¼¥¹¥±¡¼¥ë¡¿¥Í¥¬¥Æ¥£¥Ö¡¿¥¨¥Ã¥¸¸¡½Ð½èÍý ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈƱ¤¸¤Ê¤Î¤Ç¡¢¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

  • 196 ¡Á 208 ¹ÔÌÜ ( TIMER_DIFF() )

    fade_in() / fade_out() Æâ¤Ç½êÍÑ»þ´Ö¤òɽ¼¨¤·¤¿¤¤¤¿¤á¤ËÍÑ°Õ¤·¤¿¥Þ¥¯¥í¤Ç¤¹¡£struct timeval ·¿ÊÑ¿ô¤Ç¤¢¤ë start ¤È end ´Ö¤Î·Ð²á»þ´Ö¤ò·×»»¤·¤Æ¡¢Æ±¤¸¤¯ struct timeval ·¿ÊÑ¿ô¤Î diff ¤Ë³ÊǼ¤·¤Æ¤¤¤Þ¤¹¡£

  • 210 ¡Á 230 ¹ÔÌÜ ( MIX_IMAGE() )

    Á°½Ò¤Î

    ÊÑ´¹¸å¤ÎÃÍ = ratio * ÊÑ´¹Á°¤ÎÃÍ
    

    ¤Ë´ð¤Å¤¤¤ÆÊÑ´¹¸å¤ÎÁ´¥Ô¥¯¥»¥ë¤ÎÃͤò·×»»¤·¡¢·ë²Ì²èÁü¤òɽ¼¨¤¹¤ë¥Þ¥¯¥í¤Ç¤¹¡£·×»»¸å¤Ï

    • Imlib_free_pixmap() ¤Ë¤Æ´û¸¤Î Pixmap ¤ò²òÊüÂоݤËÀßÄê
    • Imlib_changed_iamge() ¤Ç Imlib ¤Ë²èÁü¥Ç¡¼¥¿¤ÎÊѹ¹¤òÄÌÃÎ
    • ¼«ºî´Ø¿ô render() ¤Ç Pixmap ¤òÀ¸À®
    • ¼«ºî´Ø¿ô update_image() ¤Ç Pixmap ¤òɽ¼¨

    ¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤Ë¤Ä¤¤¤Æ¤ÏLECTURE 21 ²èÁü¤Î¥°¥ì¡¼¥¹¥±¡¼¥ë¡¿¥Í¥¬¥Æ¥£¥Ö¡¿¥¨¥Ã¥¸¸¡½Ð½èÍý ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÈƱ¤¸¤Ê¤Î¤Ç¡¢¤½¤Á¤é¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£

  • 233 ¡Á 255 ¹ÔÌÜ ( fade_in() )

    ¥Õ¥§¡¼¥É¥¤¥ó½èÍý¤ò¹Ô¤¦´Ø¿ô¤Ç¤¹¡£246 ¡Á 249 ¹ÔÌÜ¤Ç ratio ¤ò 0 ¡Á 100 ¤Þ¤ÇÊѲ½¤µ¤»¤Ê¤¬¤é¡¢Ëè²ó MIX_IMAGE() ¤Ë¤è¤Ã¤ÆÊÑ´¹¡¿·ë²Ìɽ¼¨¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ratio ¤Ï MIX_IMAGE() Æâ¤Ç 100 ¤Ç³ä¤ë¤¿¤á¡¢·ë²ÌŪ¤Ë¥Ô¥¯¥»¥ë¤ÎÃͤò 0 ¡Á ²èÁü¤Î¥Ô¥¯¥»¥ëÃͤËÊÑ´¹¤·¤Æ¤¤¤Þ¤¹¡£

    Á°¸å¤Î½èÍý¤Ï¡¢½êÍÑ»þ´Ö¤ò·×¬¤·¤Æɽ¼¨¤·¤Æ¤¤¤ë¤À¤±¤Ç¤¹¡£

  • 258 ¡Á 280 ¹ÔÌÜ ( fade_out() )

    ¥Õ¥§¡¼¥É¥¢¥¦¥È½èÍý¤ò¹Ô¤¦´Ø¿ô¤Ç¤¹¡£271 ¡Á 274 ¹ÔÌÜ¤Ç ratio ¤ò 100 ¡Á 0 ¤Þ¤ÇÊѲ½¤µ¤»¤Ê¤¬¤é¡¢Ëè²ó MIX_IMAGE() ¤Ë¤è¤Ã¤ÆÊÑ´¹¡¿·ë²Ìɽ¼¨¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£ratio ¤Ï MIX_IMAGE() Æâ¤Ç 100 ¤Ç³ä¤ë¤¿¤á¡¢·ë²ÌŪ¤Ë¥Ô¥¯¥»¥ë¤ÎÃͤò²èÁü¤Î¥Ô¥¯¥»¥ëÃÍ ¡Á 0 ¤ËÊÑ´¹¤·¤Æ¤¤¤Þ¤¹¡£

    Á°¸å¤Î½èÍý¤Ï¡¢½êÍÑ»þ´Ö¤ò·×¬¤·¤Æɽ¼¨¤·¤Æ¤¤¤ë¤À¤±¤Ç¤¹¡£

°Ê¾å¤Ç fade.c ¤Ë¤Ä¤¤¤Æ¤ÎÀâÌÀ¤Ï½ª¤ï¤ê¤Ç¤¹¡£