These pages are written by only Japanese.
|
Namazu for hns による簡易全文検索です。 詳細は 詳細指定/ヘルプをご参照下さい。 |
||||||||||||||||||||||||||||||||||||||||||||||||
$swf = new SWFEditor() $swf->input($swfdata); $vars = array('input_value' => 'this is pen.'); $swf->setActionVariables($vars); echo $swf->output();以下の ActionScript のように変数を受け取る事ができます。
internal_value = input_value
jpeg_segment_delete_node(jpeg_segment_t *jpeg_seg, int marker) { jpeg_segment_node_t *node; int count = 0; for (node=jpeg_seg->head ; node ; node=node->next) { if (node->marker == marker) { node->marker = -1; // remove mark; if (node->data_ref) { free(node->data_ref); // ☆☆コレ☆☆ node->data_ref = NULL; } node->data_len = 0; count ++; } } return count; }わざわざ free されないように data_ref (他変数の参照だよ) という 分かりやすい変数名にしてたのに。。。シネバイイノニ。 > 自分
Program received signal SIGSEGV, Segmentation fault. 0x00c3473c in memcpy () from /lib/i686/nosegneg/libc.so.6 (gdb) bt #0 0x00c3473c in memcpy () from /lib/i686/nosegneg/libc.so.6 #1 0x03b51cb0 in __glEmptyImage () from /usr/lib/libGL.so.1コピー領域が確保できてない系の落ち方です。
#define php_array_to_long_array(z) (long *)php_array_to_c_array(z,TO_C_LONG,sizeof(long),NULL)
void *php_array_to_c_array(zval *param,int type,int size,int *array_size) { HashTable *param_ht = param->value.ht; tmp_size = zend_hash_num_elements(param_ht); zend_hash_internal_pointer_reset(param_ht); params = (void *)emalloc(size * tmp_size); while(zend_hash_get_current_data(param_ht,(void **)&cur) == SUCCESS) { convert_to_long(*cur); ((long*)params)[i] = Z_LVAL_P(*cur); zend_hash_move_forward(param_ht); i++; } return (void *)params; }文字通り、PHP の配列を C の配列にマッピングする関数です。
$pixels = array($width * $height);で実験していて、これは間違いで、
$pixels = array_fill(0, $width * $height, 0);です。
PHP_FUNCTION(glreadpixels) { <略> v_pixels = php_array_to_long_array(pixels); glReadPixels((int)Z_LVAL_P(x),(int)Z_LVAL_P(y),(int)Z_LVAL_P(width),(int)Z_LVAL_P(height),(int)Z_LVAL_P(format),(int)Z_LVAL_P(type),v_pixels); }なので、何も値が返ってきません。
ZEND_BEGIN_ARG_INFO_EX(force_ref_seventh_arg, 1, 0, 7) ZEND_ARG_INFO(0, arg1) ZEND_ARG_INFO(0, arg2) ZEND_ARG_INFO(0, arg3) ZEND_ARG_INFO(0, arg4) ZEND_ARG_INFO(0, arg5) ZEND_ARG_INFO(0, arg6) ZEND_ARG_INFO(1, arg7) ZEND_END_ARG_INFO() function_entry opengl_functions[] = { <略> PHP_FE(glreadpixels,force_ref_seventh_arg)PHP_FUNCTION(glreadpixels) の 最後に、
long_array_to_php_array(v_pixels, (int)Z_LVAL_P(width) * Z_LVAL_P(height)* 4 /*U_LONG size*/, pixels); }の一行を追加してみたけど、何も変わる様子無いです。
v_pixels_len = (int)Z_LVAL_P(width) * Z_LVAL_P(height)* sizeof(long); v_pixels = emalloc(v_pixels_len); glReadPixels((int)Z_LVAL_P(x),(int)Z_LVAL_P(y),(int)Z_LVAL_P(width),(int)Z_LVAL_P(height),(int)Z_LVAL_P(format),(int)Z_LVAL_P(type),v_pixels); long_array_to_php_array(v_pixels, v_pixels_len, pixels);
$pixels = array(); // 空配列を渡す glReadPixels(0, 0, $width, $height, GL_RGBA, GL_UNSIGNED_BYTE, $pixels);
// GD でキャンバスを作る $im = imagecreatetruecolor($width, $height); $i = 0; // pixels 配列を R, G, B, A(無視) の順で解釈してイメージを作成 for ($y = $height ; $y >= 0; $y--) { for ($x = 0; $x < $width ; $x++) { $rgb = $pixels[$i]; if ($rgb < 0) { $rgb += 4294967296; // integer => float } $blue = $rgb % 0x100 ; $rgb /= 0x100; $green = $rgb % 0x100 ; $rgb /= 0x100; $red = $rgb % 0x100 ; $rgb /= 0x100; $color = imagecolorallocate($im, $red, $green, $blue); imagesetpixel($im, $x, $y, $color); // pixel を埋めていく $i ++; } } imagepng($im, "output.png"); // PNG ファイルとして保存!!!PHP の integer は 0x80000000 以上の正の値を扱えないので、 その場合は float に格上げして、ビット演算をあきらめて mod で処理してます。 (unpack 使えって話ですね。すみません)
array(array('red'=>..., 'green'=>..., 'blue'=>..., 'alpha'=>...))の形式で返した方が良いと思いました。