view window/button.cc @ 0:223b71206888

Initial import
author thib
date Fri, 01 Aug 2008 16:32:45 +0000
parents
children b753afeb3f34
line wrap: on
line source

/*
 * Copyright (c) 2004-2006  Kazunori "jagarl" Ueno
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. The name of the author may not be used to endorse or promote products
 *    derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/* r,g,b の基本色で number (0:left 1:right 2:up 3:down)の矢印のビットマップを作成する
** width/heightのどちらかを-1にすると、それにあわせてスケール
*/
extern char* create_button(int number, int& width, int& height, int r, int g, int b);
extern char* create_box(int& width, int& height, int r, int g, int b);

// ボタンのbitmap
// ランレングスで簡易圧縮
static int buttonleft_cnt = 990;
static char buttonleft[991] = {
	0x00,0x10,0x04,0x7e,0x39,0x00,0x22,0x04,0x7f,0x59,0x00,0x1e,0x04,0x81,0x79,0x00,
	0x1a,0x04,0x83,0x99,0x00,0x17,0x04,0x84,0xb9,0x00,0x14,0x04,0x85,0xc9,0x00,0x11,
	0x04,0x87,0xd9,0xf8,0x04,0x88,0xe9,0xd8,0x04,0x89,0xf9,0xc8,0x04,0x89,0x01,0x10,
	0xa8,0x04,0x10,0x02,0x7a,0x01,0x11,0x88,0xfc,0x02,0x7e,0x01,0x10,0x78,0xdc,0x02,
	0x83,0xd9,0x68,0xdc,0x02,0x85,0xd9,0x48,0xdc,0x02,0x87,0xd9,0x38,0xcc,0x02,0x89,
	0xc9,0x28,0xcc,0x02,0x11,0x03,0x69,0x02,0x11,0xb9,0x28,0xbc,0xea,0x03,0x70,0xea,
	0xc9,0x18,0xbc,0xca,0x03,0x75,0xca,0xb9,0x18,0xac,0xca,0x03,0x77,0xca,0xa9,0x18,
	0xac,0xba,0x03,0x79,0xba,0xb9,0x9c,0xba,0x03,0x7b,0xaa,0xb9,0x9c,0xaa,0x03,0x7c,
	0xba,0xa9,0x9c,0xaa,0x03,0x7d,0xaa,0xa9,0x9c,0x9a,0x03,0x7e,0xba,0x99,0x9c,0x9a,
	0x03,0x4e,0x39,0x03,0x2e,0xaa,0x99,0x9c,0x9a,0x03,0x4c,0x69,0x03,0x2d,0xaa,0x99,
	0x9c,0x9a,0x03,0x49,0xb9,0x03,0x2b,0xaa,0x99,0x9c,0x8a,0x03,0x48,0xe9,0x03,0x2a,
	0xaa,0x99,0x9c,0x8a,0x03,0x45,0x01,0x13,0x03,0x28,0xaa,0x99,0x9c,0x8a,0x03,0x43,
	0x01,0x16,0x03,0x27,0xaa,0x99,0x9c,0x8a,0x03,0x40,0x01,0x1b,0x03,0x25,0xaa,0x99,
	0x9c,0x8a,0x03,0x3e,0x01,0x1b,0x3a,0x03,0x24,0xaa,0x99,0x9c,0x8a,0x03,0x3b,0x01,
	0x1b,0x8a,0x03,0x22,0xaa,0x99,0x9c,0x8a,0x03,0x39,0x01,0x1b,0x1d,0xaa,0x03,0x21,
	0xaa,0x99,0x9c,0x8a,0x03,0x37,0x01,0x1a,0x4d,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,
	0x03,0x34,0x01,0x1b,0x6d,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x32,0x01,0x1a,
	0x9d,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x2f,0x01,0x1b,0xbd,0xaa,0x03,0x21,
	0xaa,0x99,0x9c,0x8a,0x03,0x2d,0x01,0x1b,0xdd,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,
	0x03,0x2a,0x01,0x1b,0x05,0x10,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x28,0x01,
	0x1b,0x05,0x12,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x25,0x01,0x1b,0x05,0x15,
	0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x23,0x01,0x1b,0x05,0x17,0xaa,0x03,0x21,
	0xaa,0x99,0x9c,0x8a,0x03,0x20,0x01,0x1b,0x05,0x1a,0xaa,0x03,0x21,0xaa,0x99,0x9c,
	0x8a,0x03,0x1e,0x01,0x1b,0x05,0x1c,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x1c,
	0x01,0x1a,0x05,0x1f,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x19,0x01,0x1b,0x05,
	0x21,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x17,0x01,0x1a,0x05,0x24,0xaa,0x03,
	0x21,0xaa,0x99,0x9c,0x8a,0x03,0x14,0x01,0x1b,0x05,0x26,0xaa,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x12,0x01,0x1b,0x05,0x28,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xfb,
	0x01,0x1b,0x05,0x2b,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xdb,0x01,0x1b,0x05,0x2d,
	0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xcb,0x01,0x19,0x05,0x30,0xaa,0x03,0x21,0xaa,
	0x99,0x9c,0x8a,0xcb,0x01,0x17,0x05,0x32,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xcb,
	0x01,0x14,0x4a,0x05,0x31,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xcb,0x01,0x12,0x9a,
	0x05,0x2e,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0xcb,0xf9,0xea,0x05,0x2c,0xaa,0x03,
	0x21,0xaa,0x99,0x9c,0x8a,0xfb,0xa9,0x02,0x13,0x05,0x29,0xaa,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x12,0x69,0x02,0x16,0x05,0x27,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,
	0x03,0x16,0x19,0x02,0x19,0x05,0x25,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x18,
	0x02,0x1b,0x05,0x22,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x1b,0x02,0x1a,0x05,
	0x20,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x1d,0x02,0x1b,0x05,0x1d,0xaa,0x03,
	0x21,0xaa,0x99,0x9c,0x8a,0x03,0x20,0x02,0x1a,0x05,0x1b,0xaa,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x22,0x02,0x1a,0x05,0x19,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,
	0x24,0x02,0x1b,0x05,0x16,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x27,0x02,0x1a,
	0x05,0x14,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x29,0x02,0x1b,0x05,0x11,0xaa,
	0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x2c,0x02,0x1a,0xfd,0xaa,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x2e,0x02,0x1b,0xcd,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x31,
	0x02,0x1a,0xad,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x33,0x02,0x1a,0x8d,0xaa,
	0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x35,0x02,0x1b,0x5d,0xaa,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x38,0x02,0x1a,0x3d,0xaa,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x3a,
	0x02,0x25,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x3d,0x02,0x22,0x03,0x21,0xaa,0x99,
	0x9c,0x8a,0x03,0x3f,0x02,0x20,0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x41,0x02,0x1e,
	0x03,0x21,0xaa,0x99,0x9c,0x8a,0x03,0x44,0x02,0x1b,0x03,0x21,0xaa,0x99,0x9c,0x8a,
	0x03,0x46,0x02,0x19,0x03,0x21,0xaa,0x99,0x9c,0x9a,0x03,0x48,0x02,0x16,0x03,0x21,
	0xaa,0x99,0x9c,0x9a,0x03,0x4a,0x02,0x14,0x03,0x21,0xaa,0x99,0x9c,0x9a,0x03,0x4d,
	0x02,0x10,0x03,0x22,0xaa,0x99,0x9c,0x9a,0x03,0x4f,0xca,0x03,0x24,0xaa,0x99,0x9c,
	0x9a,0x03,0x51,0x8a,0x03,0x25,0xba,0x99,0x9c,0xaa,0x03,0x53,0x3a,0x03,0x27,0xaa,
	0xa9,0x9c,0xaa,0x03,0x7c,0xba,0xa9,0x9c,0xba,0x03,0x7b,0xba,0xa9,0x9c,0xca,0x03,
	0x79,0xba,0xb9,0xac,0xca,0x03,0x77,0xca,0xb9,0xbc,0xda,0x03,0x73,0xea,0xa9,0x28,
	0xac,0x02,0x10,0x03,0x6d,0x02,0x10,0xb9,0x28,0xac,0x02,0x8c,0xb9,0x38,0xbc,0x02,
	0x8a,0xc9,0x38,0xcc,0x02,0x89,0xc9,0x48,0xcc,0x02,0x86,0xd9,0x58,0xdc,0x02,0x84,
	0xe9,0x68,0xdc,0x02,0x82,0xe9,0x78,0xfc,0x02,0x7d,0x01,0x10,0x98,0x04,0x10,0x02,
	0x78,0x01,0x12,0xb8,0xfc,0x01,0x8a,0xb8,0xfc,0x01,0x89,0xd8,0xec,0x01,0x88,0xf8,
	0xdc,0x01,0x86,0x00,0x13,0xbc,0x01,0x85,0x00,0x15,0xac,0x01,0x84,0x00,0x17,0x9c,
	0x01,0x82,0x00,0x1b,0x7c,0x01,0x7f,0x00,0x1f,0x6c,0x01,0x7d,0x00,0x13,
	0xff};
static int buttonright_cnt = 978;
static char buttonright[979] = {
	0x00,0x13,0x04,0x81,0x00,0x21,0x04,0x84,0x00,0x1e,0x04,0x88,0x00,0x19,0x04,0x8c,
	0x00,0x17,0x04,0x8f,0x00,0x14,0x04,0x91,0x00,0x11,0x04,0x94,0xf8,0x04,0x96,0xd8,
	0x04,0x98,0xb8,0x04,0x9a,0xa8,0x04,0x11,0x02,0x7a,0x04,0x10,0x88,0xfc,0x02,0x7f,
	0xfc,0x68,0xec,0x02,0x83,0xdc,0x68,0xdc,0x02,0x85,0xdc,0x48,0xdc,0x02,0x87,0xcc,
	0x48,0xcc,0x02,0x89,0xcc,0x28,0xcc,0x02,0x11,0x03,0x11,0x02,0x11,0x03,0x47,0x02,
	0x11,0xbc,0x28,0xbc,0xea,0x03,0x71,0xea,0xbc,0x18,0xbc,0xca,0x03,0x75,0xca,0x04,
	0x16,0xca,0x03,0x77,0xca,0x04,0x15,0xba,0x03,0x79,0xba,0x04,0x14,0xba,0x03,0x7b,
	0xba,0x99,0xac,0xaa,0x03,0x7d,0xaa,0x99,0xac,0xaa,0x03,0x7d,0xaa,0x99,0x9c,0xaa,
	0x03,0x7f,0x9a,0x99,0x9c,0xaa,0x03,0x7f,0x9a,0x99,0x9c,0xaa,0x03,0x2c,0x4a,0x03,
	0x4f,0x9a,0x99,0x9c,0xaa,0x03,0x2b,0x8a,0x03,0x4c,0x9a,0x99,0x9c,0x9a,0x03,0x2a,
	0x29,0xba,0x03,0x4a,0x8a,0x99,0x9c,0x9a,0x03,0x29,0x39,0xda,0x03,0x48,0x8a,0x99,
	0x9c,0x9a,0x03,0x27,0x59,0x02,0x10,0x03,0x45,0x8a,0x99,0x9c,0x9a,0x03,0x26,0x69,
	0x02,0x12,0x03,0x43,0x8a,0x99,0x9c,0x9a,0x03,0x24,0x89,0x02,0x15,0x03,0x40,0x8a,
	0x99,0x9c,0x9a,0x03,0x23,0x99,0x02,0x17,0x03,0x3e,0x8a,0x99,0x9c,0x9a,0x03,0x23,
	0x99,0x02,0x1a,0x03,0x3b,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x1d,0x02,0x1b,0x03,
	0x39,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x3d,0x02,0x1c,0x03,0x36,0x8a,0x99,0x9c,
	0x9a,0x03,0x23,0x99,0x6d,0x02,0x1c,0x03,0x33,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,
	0x8d,0x02,0x1c,0x03,0x31,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0xbd,0x02,0x1c,0x03,
	0x2e,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0xed,0x02,0x1b,0x03,0x2c,0x8a,0x99,0x9c,
	0x9a,0x03,0x23,0x99,0x05,0x10,0x02,0x1c,0x03,0x29,0x8a,0x99,0x9c,0x9a,0x03,0x23,
	0x99,0x05,0x13,0x02,0x1b,0x03,0x27,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x15,
	0x02,0x1c,0x03,0x24,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x18,0x02,0x1b,0x03,
	0x22,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x1a,0x02,0x1c,0x03,0x1f,0x8a,0x99,
	0x9c,0x9a,0x03,0x23,0x99,0x05,0x1d,0x02,0x1c,0x03,0x1c,0x8a,0x99,0x9c,0x9a,0x03,
	0x23,0x99,0x05,0x1f,0x02,0x1c,0x03,0x1a,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,
	0x22,0x02,0x1c,0x03,0x17,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x25,0x02,0x1a,
	0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x27,0x02,0x18,0x03,0x16,0x8a,
	0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x2a,0x02,0x15,0x03,0x16,0x8a,0x99,0x9c,0x9a,
	0x03,0x23,0x99,0x05,0x2c,0x02,0x13,0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,
	0x05,0x2f,0x02,0x10,0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x31,0xea,
	0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x30,0xfa,0x03,0x16,0x8a,0x99,
	0x9c,0x9a,0x03,0x23,0x99,0x05,0x2e,0x02,0x11,0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,
	0x23,0x99,0x05,0x2b,0x02,0x14,0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,
	0x29,0x02,0x16,0x03,0x16,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x27,0x02,0x17,
	0x03,0x17,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x24,0x02,0x1a,0x03,0x17,0x8a,
	0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x22,0x02,0x1a,0x03,0x19,0x8a,0x99,0x9c,0x9a,
	0x03,0x23,0x99,0x05,0x1f,0x02,0x1b,0x03,0x1b,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,
	0x05,0x1d,0x02,0x1a,0x03,0x1e,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x1b,0x02,
	0x1a,0x03,0x20,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x18,0x02,0x1b,0x03,0x22,
	0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x05,0x16,0x02,0x1a,0x03,0x25,0x8a,0x99,0x9c,
	0x9a,0x03,0x23,0x99,0x05,0x13,0x02,0x1b,0x03,0x27,0x8a,0x99,0x9c,0x9a,0x03,0x23,
	0x99,0x05,0x11,0x02,0x1a,0x03,0x2a,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0xed,0x02,
	0x1b,0x03,0x2c,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0xcd,0x02,0x1a,0x03,0x2f,0x8a,
	0x99,0x9c,0x9a,0x03,0x23,0x99,0xad,0x02,0x1a,0x03,0x31,0x8a,0x99,0x9c,0x9a,0x03,
	0x23,0x99,0x7d,0x02,0x1b,0x03,0x33,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x5d,0x02,
	0x1a,0x03,0x36,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x2d,0x02,0x1b,0x03,0x38,0x8a,
	0x99,0x9c,0x9a,0x03,0x23,0x99,0x02,0x1a,0x03,0x3b,0x8a,0x99,0x9c,0x9a,0x03,0x23,
	0x99,0x02,0x18,0x03,0x3d,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x02,0x16,0x03,0x3f,
	0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0x02,0x13,0x03,0x42,0x8a,0x99,0x9c,0x9a,0x03,
	0x23,0x99,0x02,0x11,0x03,0x44,0x8a,0x99,0x9c,0x9a,0x03,0x23,0x99,0xea,0x03,0x47,
	0x8a,0x99,0x9c,0xaa,0x03,0x22,0x99,0xca,0x03,0x48,0x9a,0x99,0x9c,0xaa,0x03,0x22,
	0x99,0x9a,0x03,0x4b,0x9a,0x99,0x9c,0xaa,0x03,0x22,0x99,0x7a,0x03,0x4d,0x9a,0x99,
	0x9c,0xaa,0x03,0x24,0x79,0x5a,0x03,0x4f,0x9a,0x99,0x9c,0xaa,0x03,0x26,0x59,0x2a,
	0x03,0x51,0xaa,0x01,0x13,0xaa,0x03,0x27,0x39,0x03,0x53,0xaa,0x01,0x13,0xaa,0x03,
	0x7c,0xba,0x01,0x13,0xba,0x03,0x7b,0xba,0x01,0x14,0xba,0x03,0x79,0xca,0x01,0x14,
	0xca,0x03,0x77,0xba,0xb9,0x18,0xa9,0xea,0x03,0x73,0xda,0xb9,0x18,0xb9,0x02,0x10,
	0x03,0x6d,0x02,0x10,0xa9,0x28,0xc9,0x02,0x8b,0xb9,0x38,0xb9,0x02,0x8b,0xb9,0x38,
	0xc9,0x02,0x89,0xb9,0x48,0xe9,0x02,0x86,0xc9,0x58,0xe9,0x02,0x84,0xd9,0x68,0xe9,
	0x02,0x82,0xd9,0x88,0x01,0x10,0x02,0x7d,0xe9,0x98,0x01,0x13,0x02,0x78,0x01,0x10,
	0xa8,0x01,0x99,0xc8,0x01,0x97,0xe8,0x01,0x95,0x00,0x10,0x01,0x93,0x00,0x13,0x01,
	0x90,0x00,0x15,0x01,0x8e,0x00,0x18,0x01,0x8a,0x00,0x1d,0x01,0x86,0x00,0x20,0x01,
	0x83,0xe8,
	0xff};
static int buttonup_cnt = 1288;
static char buttonup[1289] = {
	0x00,0x10,0x04,0x4c,0x00,0x20,0x04,0x52,0x00,0x1a,0x04,0x56,0x00,0x17,0x04,0x59,
	0x00,0x14,0x04,0x5b,0x00,0x12,0x04,0x5e,0xe8,0x04,0x61,0xd8,0x04,0x62,0xb8,0x04,
	0x64,0x98,0x04,0x10,0x02,0x45,0x04,0x10,0x88,0xfc,0x02,0x48,0x04,0x10,0x78,0xdc,
	0x02,0x4c,0xfc,0x58,0xdc,0x02,0x4f,0xdc,0x48,0xdc,0x02,0x51,0xdc,0x38,0xcc,0x02,
	0x53,0xcc,0x38,0xbc,0x02,0x55,0x04,0x18,0x02,0x57,0x04,0x17,0x02,0x10,0x03,0x35,
	0x02,0x12,0x04,0x16,0xda,0x03,0x3e,0xea,0x04,0x15,0xba,0x03,0x42,0xca,0x04,0x14,
	0xba,0x03,0x44,0xca,0x99,0xac,0xaa,0x03,0x46,0xba,0x99,0xac,0x9a,0x03,0x48,0xaa,
	0x99,0xac,0x8a,0x03,0x49,0xaa,0x99,0xac,0x8a,0x03,0x4a,0x9a,0x99,0xac,0x8a,0x03,
	0x4a,0x9a,0x99,0xac,0x7a,0x03,0x4c,0x8a,0x99,0xac,0x7a,0x03,0x4c,0x8a,0x99,0xac,
	0x7a,0x03,0x4c,0x8a,0x99,0xac,0x6a,0x03,0x25,0x59,0x03,0x23,0x8a,0x99,0xac,0x6a,
	0x03,0x24,0x69,0x03,0x23,0x8a,0x99,0xac,0x6a,0x03,0x24,0x69,0x03,0x23,0x8a,0x99,
	0xac,0x6a,0x03,0x23,0x89,0x03,0x22,0x8a,0x99,0xac,0x6a,0x03,0x23,0x89,0x03,0x22,
	0x8a,0x99,0xac,0x6a,0x03,0x23,0x89,0x03,0x22,0x8a,0x99,0xac,0x6a,0x03,0x22,0xa9,
	0x03,0x21,0x8a,0x99,0xac,0x6a,0x03,0x22,0xa9,0x03,0x21,0x8a,0x99,0xac,0x6a,0x03,
	0x21,0xb9,0x03,0x21,0x8a,0x99,0xac,0x6a,0x03,0x21,0xb9,0x03,0x21,0x8a,0x99,0xac,
	0x6a,0x03,0x21,0xc9,0x03,0x20,0x8a,0x99,0xac,0x6a,0x03,0x20,0xd9,0x03,0x20,0x8a,
	0x99,0xac,0x6a,0x03,0x20,0xb9,0x3a,0x03,0x1f,0x8a,0x99,0xac,0x6a,0x03,0x1f,0xb9,
	0x4a,0x03,0x1f,0x8a,0x99,0xac,0x6a,0x03,0x1f,0xb9,0x4a,0x03,0x1f,0x8a,0x99,0xac,
	0x6a,0x03,0x1f,0xa9,0x6a,0x03,0x1e,0x8a,0x99,0xac,0x6a,0x03,0x1e,0xb9,0x6a,0x03,
	0x1e,0x8a,0x99,0xac,0x6a,0x03,0x1e,0xb9,0x7a,0x03,0x1d,0x8a,0x99,0xac,0x6a,0x03,
	0x1d,0xb9,0x8a,0x03,0x1d,0x8a,0x99,0xac,0x6a,0x03,0x1d,0xb9,0x8a,0x03,0x1d,0x8a,
	0x99,0xac,0x6a,0x03,0x1d,0xa9,0xaa,0x03,0x1c,0x8a,0x99,0xac,0x6a,0x03,0x1c,0xb9,
	0xaa,0x03,0x1c,0x8a,0x99,0xac,0x6a,0x03,0x1c,0xb9,0xba,0x03,0x1b,0x8a,0x99,0xac,
	0x6a,0x03,0x1b,0xb9,0x1d,0xba,0x03,0x1b,0x8a,0x99,0xac,0x6a,0x03,0x1b,0xb9,0x2d,
	0xba,0x03,0x1a,0x8a,0x99,0xac,0x6a,0x03,0x1b,0xa9,0x3d,0xba,0x03,0x1a,0x8a,0x99,
	0xac,0x6a,0x03,0x1a,0xb9,0x3d,0xba,0x03,0x1a,0x8a,0x99,0xac,0x6a,0x03,0x1a,0xb9,
	0x4d,0xba,0x03,0x19,0x8a,0x99,0xac,0x6a,0x03,0x19,0xb9,0x5d,0xba,0x03,0x19,0x8a,
	0x99,0xac,0x6a,0x03,0x19,0xb9,0x6d,0xba,0x03,0x18,0x8a,0x99,0xac,0x6a,0x03,0x18,
	0xb9,0x7d,0xba,0x03,0x18,0x8a,0x99,0xac,0x6a,0x03,0x18,0xb9,0x7d,0xba,0x03,0x18,
	0x8a,0x99,0xac,0x6a,0x03,0x18,0xb9,0x8d,0xba,0x03,0x17,0x8a,0x99,0xac,0x6a,0x03,
	0x17,0xb9,0x9d,0xba,0x03,0x17,0x8a,0x99,0xac,0x6a,0x03,0x17,0xb9,0xad,0xba,0x03,
	0x16,0x8a,0x99,0xac,0x6a,0x03,0x16,0xb9,0xbd,0xba,0x03,0x16,0x8a,0x99,0xac,0x6a,
	0x03,0x16,0xb9,0xcd,0xaa,0x03,0x16,0x8a,0x99,0xac,0x6a,0x03,0x16,0xb9,0xcd,0xba,
	0x03,0x15,0x8a,0x99,0xac,0x6a,0x03,0x15,0xb9,0xdd,0xba,0x03,0x15,0x8a,0x99,0xac,
	0x6a,0x03,0x15,0xb9,0xed,0xba,0x03,0x14,0x8a,0x99,0xac,0x6a,0x03,0x14,0xb9,0xfd,
	0xba,0x03,0x14,0x8a,0x99,0xac,0x6a,0x03,0x14,0xb9,0x05,0x10,0xba,0x03,0x13,0x8a,
	0x99,0xac,0x6a,0x03,0x14,0xa9,0x05,0x11,0xba,0x03,0x13,0x8a,0x99,0xac,0x6a,0x03,
	0x13,0xb9,0x05,0x11,0xba,0x03,0x13,0x8a,0x99,0xac,0x6a,0x03,0x13,0xb9,0x05,0x12,
	0xba,0x03,0x12,0x8a,0x99,0xac,0x6a,0x03,0x12,0xb9,0x05,0x13,0xba,0x03,0x12,0x8a,
	0x99,0xac,0x6a,0x03,0x12,0xb9,0x05,0x14,0xba,0x03,0x11,0x8a,0x99,0xac,0x6a,0x03,
	0x12,0xa9,0x05,0x15,0xba,0x03,0x11,0x8a,0x99,0xac,0x6a,0x03,0x11,0xb9,0x05,0x16,
	0xaa,0x03,0x11,0x8a,0x99,0xac,0x6a,0x03,0x11,0xb9,0x05,0x16,0xba,0x03,0x10,0x8a,
	0x99,0xac,0x6a,0x03,0x10,0xb9,0x05,0x17,0xba,0x03,0x10,0x8a,0x99,0xac,0x6a,0x03,
	0x10,0xb9,0x05,0x18,0xba,0xfb,0x8a,0x99,0xac,0x6a,0xfb,0xb9,0x05,0x19,0xba,0xfb,
	0x8a,0x99,0xac,0x6a,0xfb,0xb9,0x05,0x1a,0xba,0xeb,0x8a,0x99,0xac,0x6a,0xfb,0xb9,
	0x05,0x1a,0xba,0xeb,0x8a,0x99,0xac,0x6a,0xeb,0xb9,0x05,0x1b,0xba,0xeb,0x8a,0x99,
	0xac,0x6a,0xeb,0xb9,0x05,0x1c,0xba,0xdb,0x8a,0x99,0xac,0x6a,0xdb,0xb9,0x05,0x1d,
	0xba,0xdb,0x8a,0x99,0xac,0x6a,0xdb,0xb9,0x05,0x1e,0xba,0xcb,0x8a,0x99,0xac,0x6a,
	0xdb,0xb9,0x05,0x1e,0xba,0xcb,0x8a,0x99,0xac,0x6a,0xcb,0xb9,0x05,0x1f,0xba,0xcb,
	0x8a,0x99,0xac,0x6a,0xcb,0xb9,0x05,0x20,0xba,0xbb,0x8a,0x99,0xac,0x6a,0xbb,0xb9,
	0x05,0x21,0xba,0xbb,0x8a,0x99,0xac,0x6a,0xbb,0xb9,0x05,0x22,0xba,0xab,0x8a,0x99,
	0xac,0x6a,0xbb,0xb9,0x05,0x22,0xba,0xab,0x8a,0x99,0xac,0x6a,0xab,0xb9,0x05,0x24,
	0xaa,0xab,0x8a,0x99,0xac,0x6a,0xab,0xb9,0x05,0x24,0xba,0x9b,0x8a,0x99,0xac,0x6a,
	0x9b,0xb9,0x05,0x25,0xba,0x9b,0x8a,0x99,0xac,0x6a,0x9b,0xb9,0x05,0x26,0xba,0x8b,
	0x8a,0x99,0xac,0x6a,0x9b,0xa9,0x05,0x27,0xba,0x8b,0x8a,0x99,0xac,0x6a,0xab,0x99,
	0x05,0x28,0xba,0x7b,0x8a,0x99,0xac,0x6a,0xab,0x99,0x05,0x28,0xba,0x7b,0x8a,0x99,
	0xac,0x6a,0xbb,0x79,0x05,0x29,0xba,0x7b,0x8a,0x99,0xac,0x6a,0xcb,0x69,0x02,0x35,
	0x6b,0x8a,0x99,0xac,0x6a,0xcb,0x59,0x02,0x36,0x6b,0x8a,0x99,0xac,0x6a,0xdb,0x49,
	0x02,0x36,0x6b,0x8a,0x99,0xac,0x6a,0xeb,0x39,0x02,0x35,0x7b,0x8a,0x99,0xac,0x6a,
	0xeb,0x29,0x02,0x36,0x7b,0x8a,0x99,0xac,0x6a,0xfb,0x19,0x02,0x35,0x8b,0x8a,0x99,
	0xac,0x6a,0x03,0x10,0x02,0x35,0x8b,0x8a,0x99,0xac,0x6a,0x03,0x10,0x02,0x34,0x9b,
	0x8a,0x99,0xac,0x6a,0x03,0x11,0x02,0x33,0x9b,0x8a,0x99,0xac,0x6a,0x03,0x12,0x02,
	0x31,0xab,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,
	0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,
	0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,
	0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,
	0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,
	0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,
	0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,
	0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x6a,0x03,0x4d,
	0x8a,0x99,0xac,0x6a,0x03,0x4d,0x8a,0x99,0xac,0x7a,0x03,0x4c,0x8a,0x99,0xac,0x7a,
	0x03,0x4c,0x8a,0x99,0xac,0x7a,0x03,0x4b,0x9a,0x99,0xac,0x8a,0x03,0x4a,0x9a,0x99,
	0xac,0x8a,0x03,0x4a,0x9a,0x99,0xac,0x8a,0x03,0x49,0xaa,0x99,0xac,0x9a,0x03,0x48,
	0x9a,0xa9,0xac,0xaa,0x03,0x46,0xaa,0x01,0x15,0xaa,0x03,0x44,0xba,0x01,0x15,0xba,
	0x03,0x41,0xca,0x01,0x17,0xda,0x03,0x3c,0xea,0xb9,0x18,0xb9,0x02,0x10,0x03,0x35,
	0x02,0x12,0xa9,0x28,0xb9,0x02,0x56,0xb9,0x38,0xb9,0x02,0x54,0xc9,0x38,0xc9,0x02,
	0x52,0xc9,0x58,0xc9,0x02,0x51,0xc9,0x58,0xd9,0x02,0x4e,0xd9,0x78,0xe9,0x02,0x4b,
	0xe9,0x78,0xf9,0x02,0x49,0xe9,0x98,0x01,0x11,0x02,0x43,0x01,0x10,0xb8,0x01,0x12,
	0x02,0x3e,0x01,0x13,0xc8,0x01,0x61,0xe8,0x01,0x5f,0x00,0x10,0x01,0x5d,0x00,0x12,
	0x01,0x5b,0x00,0x14,0x01,0x58,0x00,0x18,0x01,0x55,0x00,0x1b,0x01,0x51,0x00,0x1f,
	0x01,0x4d,0x00,0x22,0x01,0x49,0x00,0x13,
	0xff};
static int buttondown_cnt = 1445;
static char buttondown[1446] = {
	0x1e,0x00,0x12,0x04,0x45,0x59,0x00,0x11,0x1e,0xf8,0x04,0x48,0x89,0xe8,0x1e,0xd8,
	0x04,0x4a,0xa9,0xc8,0x1e,0xb8,0x04,0x4c,0xb9,0xb8,0x1e,0xa8,0x04,0x4d,0xc9,0xa8,
	0x1e,0x88,0x04,0x4f,0xe9,0x88,0x1e,0x78,0x04,0x50,0xf9,0x78,0x1e,0x68,0x04,0x51,
	0x01,0x10,0x68,0x1e,0x68,0x04,0x51,0x01,0x11,0x58,0x1e,0x58,0x04,0x12,0x02,0x40,
	0x01,0x11,0x58,0x1e,0x48,0x04,0x10,0x02,0x46,0xf9,0x48,0x1e,0x38,0xec,0x02,0x4b,
	0xe9,0x38,0x1e,0x38,0xdc,0x02,0x4d,0xd9,0x38,0x1e,0x28,0xdc,0x02,0x4f,0xd9,0x28,
	0x1e,0x28,0xcc,0x02,0x51,0xc9,0x28,0x1e,0x18,0xcc,0x02,0x53,0xc9,0x18,0x1e,0x18,
	0xbc,0x02,0x55,0xb9,0x18,0x1e,0x18,0xbc,0x02,0x56,0xa9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c,0x7a,0x03,0x13,0xb9,0x05,0x11,0xba,0x03,0x13,0x7a,0x99,0x1e,0x9c,
	0x7a,0x03,0x13,0xb9,0x05,0x11,0xba,0x03,0x13,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x13,
	0xb9,0x05,0x11,0xaa,0x03,0x14,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x14,0xb9,0xfd,0xba,
	0x03,0x14,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x14,0xb9,0xfd,0xba,0x03,0x14,0x7a,0x99,
	0x1e,0x9c,0x7a,0x03,0x15,0xa9,0xed,0xba,0x03,0x15,0x7a,0x99,0x1e,0x9c,0x7a,0x03,
	0x15,0xb9,0xdd,0xba,0x03,0x15,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x15,0xb9,0xcd,0xba,
	0x03,0x16,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x16,0xb9,0xbd,0xba,0x03,0x16,0x7a,0x99,
	0x1e,0x9c,0x7a,0x03,0x16,0xb9,0xbd,0xba,0x03,0x16,0x7a,0x99,0x1e,0x9c,0x7a,0x03,
	0x17,0xa9,0xad,0xba,0x03,0x17,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x17,0xb9,0x9d,0xba,
	0x03,0x17,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x17,0xb9,0x8d,0xba,0x03,0x18,0x7a,0x99,
	0x1e,0x9c,0x7a,0x03,0x18,0xb9,0x7d,0xba,0x03,0x18,0x7a,0x99,0x1e,0x9c,0x7a,0x03,
	0x18,0xb9,0x7d,0xba,0x03,0x18,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x18,0xb9,0x6d,0xba,
	0x03,0x19,0x7a,0x99,0x1e,0x9c,0x7a,0x03,0x18,0xc9,0x5d,0xba,0x03,0x19,0x7a,0x99,
	0x1e,0x9c,0x7a,0x03,0x19,0xb9,0x4d,0xba,0x03,0x1a,0x7a,0x99,0x1e,0x9c,0x7a,0x03,
	0x19,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x4d,0x7a,0x99,0x1e,0xac,
	0x6a,0x03,0x4d,0x7a,0x99,0x1e,0xac,0x6a,0x03,0x4d,0x7a,0x99,0x1e,0xac,0x6a,0x03,
	0x4d,0x7a,0x99,0x1e,0xac,0x6a,0x03,0x4d,0x7a,0x99,0x1e,0xac,0x6a,0x03,0x4d,0x7a,
	0x99,0x1e,0xac,0x6a,0x03,0x4d,0x7a,0x99,0x1e,0xac,0x6a,0x03,0x4c,0x8a,0x99,0x1e,
	0xac,0x7a,0x03,0x4b,0x8a,0x99,0x1e,0xac,0x7a,0x03,0x4b,0x8a,0x99,0x1e,0xac,0x7a,
	0x03,0x4a,0x9a,0x99,0x1e,0xac,0x7a,0x03,0x4a,0x9a,0x99,0x1e,0xac,0x8a,0x03,0x48,
	0xaa,0x99,0x1e,0xac,0x9a,0x03,0x47,0xaa,0x99,0x1e,0xac,0xaa,0x03,0x45,0xba,0x99,
	0x1e,0xac,0xba,0x03,0x43,0xca,0x99,0x1e,0xac,0xca,0x03,0x40,0xda,0xa9,0x1e,0xbc,
	0xea,0x03,0x3a,0x02,0x10,0xa9,0x1e,0xbc,0x02,0x57,0xb9,0x1e,0x18,0xbc,0x02,0x56,
	0xb9,0x1e,0x18,0xcc,0x02,0x54,0xc9,0x1e,0x28,0xcc,0x02,0x52,0xc9,0x18,0x1e,0x28,
	0xdc,0x02,0x50,0xd9,0x18,0x1e,0x38,0xdc,0x02,0x4e,0xd9,0x28,0x1e,0x38,0xfc,0x02,
	0x4a,0xf9,0x28,0x1e,0x48,0xfc,0x02,0x46,0x01,0x11,0x38,0x1e,0x58,0xec,0x01,0x56,
	0x48,0x1e,0x68,0xdc,0x01,0x55,0x58,0x1e,0x78,0xcc,0x01,0x55,0x58,0x1e,0x78,0xcc,
	0x01,0x53,0x78,0x1e,0x98,0xac,0x01,0x52,0x88,0x1e,0xa8,0x9c,0x01,0x51,0x98,0x1e,
	0xb8,0x8c,0x01,0x4f,0xb8,0x1e,0xd8,0x6c,0x01,0x4d,0xd8,0x1e,0xf8,0x4c,0x01,0x4a,
	0x00,0x10,0x1e,0x00,0x6d,
	0xff};

static char* extract_button(int number, int& width, int& height) {
	int size;
	char* data;

	switch(number) {
	case 0: data = buttonleft; size = buttonleft_cnt; width = 164; height = 110; break;
	case 1: data = buttonright; size = buttonright_cnt; width = 164; height = 110; break;
	case 2: data = buttonup; size = buttonup_cnt; width = 110; height = 164; break;
	case 3: data = buttondown; size = buttondown_cnt; width = 110; height = 164; break;
	default: return 0;
	}

	char* out = new char[width*height];
	int outc = 0;
	int i;
	// ランレングスの展開
	for (i=0; i<size; i++) {
		int c = *(unsigned char*)(data+i);
		int s = 0;
		if (c == 0xff) break;
		if (c&0x08) {
			s = c>>4;
			c &= 7;
		} else {
			i++;
			s = *(unsigned char*)(data + i);
		}
		int j; for (j=0; j<s; j++) out[outc++] = c;
	}
	return out;
}

// R,G,B の指定色を基底色に、明るさを変えた色を RGB -> HLS -> RGB 変換で作成する
struct ButtonColor {
	int rs[8];
	int gs[8];
	int bs[8];
	int as[8];
	int* c_min, *c_mid, *c_max; // rgb->hls->rgb変換用。r,g,b を高い順にmax,mid,minに割り当てる
	bool is_gray;
	int hc, hd, l, s; // h,l,s 系。h 要素は上の c_min|mid|maxにも入る
	ButtonColor(int _r, int _g, int _b);
	void SetBrightness1(int n, int c1);
	void SetBrightness(int c1, int c2, int c3, int c4, int c5);
};
ButtonColor::ButtonColor(int r, int g, int b) {
	is_gray = false;
	if (r == g && r == b) {
		is_gray = true;
		l = r;
		return;
	}
	*rs = r; *bs = b; *gs = g;
	
	// r,g,b の昇順にmax,mid,minをrs,gs,bsに割り当てる
	if (r > g) {
		if (r > b) { // r = max
			c_max = rs;
			if (b > g) { // r>b>g
				c_mid = bs;
				c_min = gs;
			} else { // r>g>b
				c_mid = gs;
				c_min = bs;
			}
		} else { // b>r>g
			c_max = bs;
			c_mid = rs;
			c_min = gs;
		}
	} else if (g > b) { // g = max
		c_max = gs;
		if (r > b) { // g > r > b
			c_mid = rs;
			c_min = bs;
		} else { // g > b > r
			c_mid = bs;
			c_min = rs;
		}
	} else { // b > g > r
		c_max = bs;
		c_mid = gs;
		c_min = rs;
	}
	int min = *c_min;
	int mid = *c_mid;
	int max = *c_max;
	l = (max+min)/2;
	hd = max-min;
	hc = mid - min;
	if (l < 128) s = (hd*255)/(max+min);
	else s = (hd*255) / (510-(max+min));
}
void ButtonColor::SetBrightness1(int n, int c1) {
	if (n < 1 || n > 7) return;
	as[n] = 255;
	if (is_gray) {
		rs[n] = c1 * l / 256;
		gs[n] = c1 * l / 256;
		bs[n] = c1 * l / 256;
		return;
	}
	int m1, m2;

	int light = (l * c1 * 2) / 256;
	if (light > 255) light = 255;

	if (light < 128) m2 = light*(255+s)/255;
	else m2 = light+s-(light*s/255);
	m1 = light*2 - m2;

	c_max[n] = m2;
	c_mid[n] = (hc*m2 + (hd-hc)*m1) / hd;
	c_min[n] = m1;

	return;
}
void ButtonColor::SetBrightness(int c1, int c2, int c3, int c4, int c5) {
	rs[0] = bs[0] = gs[0] = as[0] = 0;
	SetBrightness1(1, c1);
	SetBrightness1(2, c2);
	SetBrightness1(3, c3);
	SetBrightness1(4, c4);
	SetBrightness1(5, c5);
}

#include"rect.h"
#include<string.h>

static void draw_button(char* rdata, int width, int height, char* bdata, int bwidth, int bheight, const ButtonColor& color) {
	const int* rs = color.rs;
	const int* gs = color.gs;
	const int* bs = color.bs;
	const int* as = color.as;

	struct ScaleData {int r,g,b,a,c;};
	ScaleData* data = new ScaleData[width*height];
	memset(data, 0, sizeof(ScaleData)*width*height);

	int bx,by;
	int x=0, y=0;
	int x2 = 0, y2 = 0;
	int xadd = width*65536/bwidth;
	int yadd = height*65536/bheight;

	// 元のビットマップに着色しながら縮小する
	for (by=0; by<bheight; by++) {
		ScaleData* d = data + y*width;
		char* s = bdata + by*bwidth;
		x = 0; x2 = 0;
		for (bx=0; bx<bwidth; bx++) {
			int c = *s++;
			d[x].r += rs[c];
			d[x].g += gs[c];
			d[x].b += bs[c];
			d[x].a += as[c];
			d[x].c++;
			x2 += xadd;
			x += x2>>16;
			x2 &= 0xffff;
		}

		y2 += yadd;
		y += y2>>16;
		y2 &= 0xffff;
	}

	for (y=0; y<height; y++) {
		ScaleData* d = data + y*width;
		char* rd = rdata + y*width*4;
		for (x=0; x<width; x++) {
			if (d->c == 0) *(int*)rd = 0;
			else *(int*)rd = (int(d->b / d->c)&0xff)| ((int(d->g / d->c)&0xff)<<8)| ((int(d->r / d->c)&0xff)<<16)| ((int(d->a / d->c)&0xff)<<24);
			rd += 4;
			d++;
		}
	}
	delete[] data;
	return;
}
char* create_button(int number, int& width, int& height, int r, int g, int b) {
	int bwidth, bheight;
	char* bdata = extract_button(number, bwidth, bheight);
	if (bdata == 0) return 0;
	// 拡大率に合わせてwidth,heightをセット
	if (width == -1 && height == -1) width = bwidth, height = bheight;
	else if (width == -1) width = bwidth * height / bheight;
	else if (height == -1) height = bheight * width / bwidth;
	if (width > bwidth) width = bwidth;
	if (height > bheight) height = bheight;

	// 色を設定する
	ButtonColor color(r,g,b);
	// 描画
	char* rdata = (char*)malloc(width*height*4*3);
	color.SetBrightness(0x60, 0xa0, 0xc0, 0xe0, 0xe0);
	draw_button(rdata, width, height, bdata, bwidth, bheight, color);
	color.SetBrightness(0x60, 0xa0, 0xe0, 0xe0, 0xe0);
	draw_button(rdata+width*height*4, width, height, bdata, bwidth, bheight, color);
	color.SetBrightness(0xe0, 0xc0, 0xa0, 0x60, 0xa0);
	draw_button(rdata+width*height*8, width, height, bdata, bwidth, bheight, color);
	return rdata;
}

static void drawbox(char* buf, const Rect& region, int width, int r, int g, int b, int a) {
	buf += region.ty*width*4 + region.lx*4;
	int i,j;
	int h = region.height();
	int w = region.width();
	int col = (b&0xff) | ((g&0xff)<<8)| ((r&0xff)<<16)| ((a&0xff)<<24);
	for (i=0; i<h; i++) {
		char* c = buf;
		for (j=0; j<w; j++) {
			*(int*)c = col;
			c += 4;
		}
		buf += width*4;
	}
	return;
}
static void draw_box(char* buf, int width, int height, int kage_w1, int kage_w2, const ButtonColor& color) {
	const int* rs = color.rs;
	const int* gs = color.gs;
	const int* bs = color.bs;
	const int* as = color.as;
	// まず、豆腐を書く
	drawbox(buf, Rect(0,0,width,height), width, rs[3],gs[3],bs[3],as[3]);
	// 影
	if (height > 2) {
		drawbox(buf, Rect(0,0,width,kage_w1), width, rs[4], gs[4], bs[4],as[4]);
		drawbox(buf, Rect(0,height-kage_w1,width,height), width, rs[1], gs[1], bs[1],as[1]);
	}
	if (width >  2) {
		drawbox(buf, Rect(0,0,kage_w1, height), width, rs[4], gs[4], bs[4],as[4]);
		drawbox(buf, Rect(width-kage_w1,0,width,height), width, rs[1], gs[1], bs[1],as[1]);
	}
	if (height > 4) {
		drawbox(buf, Rect(kage_w2, height-kage_w2, width-kage_w1, height-kage_w1), width, rs[2], gs[2], bs[2], as[2]);
	}
	if (width > 4) {
		drawbox(buf, Rect(width-kage_w2, kage_w2, width-kage_w1, height-kage_w1), width, rs[2], gs[2], bs[2], as[2]);
	}
}
char* create_box(int& width, int& height, int r, int g, int b) {
	ButtonColor color(r,g,b);
	// scale のカーソル
	if (width == -1 && height == -1) width = 32, height = 48;
	else if (width == -1) width = height*3/2;
	else if (height == -1) height = width * 3/2;
	int kage_w1 = (width<height ? width : height)/14;
	int kage_w2 = (width<height ? width : height)*2/14;
	if (kage_w1 <= 0) kage_w1 = 1;
	if (kage_w2 <= 1) kage_w2 = 2;
	
	char* buf = (char*)malloc(width*height*4*3);
	// 描画
	color.SetBrightness(0x60, 0xa0, 0xc0, 0xe0, 0xe0);
	draw_box(buf, width, height, kage_w1, kage_w2, color);
	color.SetBrightness(0x60, 0xa0, 0xe0, 0xe0, 0xe0);
	draw_box(buf+width*height*4, width, height, kage_w1, kage_w2, color);
	color.SetBrightness(0xe0, 0xc0, 0xa0, 0x60, 0xa0);
	draw_box(buf+width*height*8, width, height, kage_w1, kage_w2, color);
	return buf;
}

#if 0
#include<stdio.h>
#include <png.h>

void create_png(FILE* stream,int width, int height, char* data) {
	png_structp png_ptr;
	png_infop info_ptr;

	/* create struct */
	png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
	if (png_ptr == NULL) return;

	/* initialize information */
	info_ptr = png_create_info_struct(png_ptr);
	if (info_ptr == NULL) {
		png_destroy_write_struct(&png_ptr, (png_infop*)NULL);
		return;
	}

	if (setjmp(png_jmpbuf(png_ptr))) {
		/* error occured !! */
		png_destroy_write_struct(&png_ptr,&info_ptr);
		return;
	}

	/* initialize I/O (for stream) */
	png_init_io(png_ptr, stream);

	/* initialize headers */
	png_set_IHDR(png_ptr, info_ptr,
		width, height, 8 /* bit_dept */,
		PNG_COLOR_TYPE_RGB_ALPHA,
		PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
	/* create text information */
	png_text info_text[3];
	info_text[0].key = "Title";
	info_text[0].text= "file";
	info_text[0].compression = PNG_TEXT_COMPRESSION_NONE;
	info_text[1].key = "Author";
	info_text[1].text="";
	info_text[1].compression = PNG_TEXT_COMPRESSION_NONE;
	info_text[2].key = "Description";
	info_text[2].text= "";
	info_text[2].compression = PNG_TEXT_COMPRESSION_NONE;
	png_set_text(png_ptr, info_ptr, info_text, 3);

	/* write information */
	png_write_info(png_ptr, info_ptr);

	/* write body */
	/* rgba image ; input/output is 32bpp.*/
	char* row = new char[width*4];
	int i; for (i=0; i<height; i++) {
		char* row_ptr = row;
		int j; for (j=0; j<width; j++) {
			row_ptr[0] = data[2];
			row_ptr[1] = data[1];
			row_ptr[2] = data[0];
			row_ptr[3] = data[3];
			row_ptr += 4; data += 4;
		}
		png_write_rows(png_ptr, (png_byte**)&row, 1);
	}
	png_write_end(png_ptr, info_ptr);
	png_destroy_write_struct(&png_ptr, &info_ptr);
	return;
}
int main(void) {
	int w=128,h=-1;
	char* c = create_button(2, w,h,0x20,0x60,0xc0);
//	char* c = create_box(w,h,0xff,0xff,0xff);
	int i;
	FILE* f=fopen("bt.png","wb");
	if(f==0)return 0;
	create_png(f,w,h*3,c);
	for (i=0;i<w*h;i++) {
		printf("%08x,",*(int*)(c+i*4));
		if ( (i&7)==7) printf("\n");
	}
	return 0;
}

#endif