Class: Rixmap::ImageIO::BaseImageIO
- Inherits:
-
Object
- Object
- Rixmap::ImageIO::BaseImageIO
- Defined in:
- src/rixmapio.cxx,
src/rixmapio.cxx
Overview
画像入出力処理のベースクラス.
Direct Known Subclasses
Format::BMP::BMPImageIO, Format::PCX::PCXImageIO, Format::PNG::PNGImageIO, Format::XPM::XPM1ImageIO, Format::XPM::XPM2ImageIO, Format::XPM::XPMImageIO
Class Method Summary collapse
-
.readable?(argMagic) ⇒ Boolean
画像の先頭バイトからその画像がこのクラスで読み込めるかを判定します.
-
.writable?(argImage) ⇒ Boolean
指定画像がこのクラスで書き込めるかを判定します.
Instance Method Summary collapse
-
#decode(data, options = {}) ⇒ Rixmap::Image
バイト列から画像を復元します.
-
#encode(image, options = {}) ⇒ String
画像をバイト列へと変換します.
-
#initialize(options = {})
constructor
private
画像入出力実装クラスを初期化します.
-
#open(path, options = {}) ⇒ Rixmap::Image
指定したパスから画像を読み込みます.
-
#read(io, options = {}) ⇒ Rixmap::Image
指定されたストリームから画像を読み込みます.
-
#readable?(argMagic) ⇒ Boolean
画像の先頭バイトからその画像がこのオブジェクトで読み込めるかどうかを判定します.
-
#save(path, image, options = {}) ⇒ Integer
指定したパスへ画像を書き出します.
-
#writable?(argImage) ⇒ Boolean
画像がこのオブジェクトで書き込めるかを判定します.
-
#write(io, image, options = {}) ⇒ Integer
指定したストリームへ画像を書き込みます.
Constructor Details
#initialize(options = {}) (private)
画像入出力実装クラスを初期化します.
オプションパラメータが指定されている場合は、キーをインスタンス変数名として値を設定していきます.
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
# File 'src/rixmapio.cxx', line 334 static VALUE BaseImageIO_initialize(int argc, VALUE* argv, VALUE self) { VALUE argOptions = Qnil; rb_scan_args(argc, argv, "01", &argOptions); VALUE objOptions = Qnil; if (NIL_P(argOptions)) { objOptions = rb_hash_new(); } else { if (RB_TYPE_P(argOptions, T_HASH)) { objOptions = argOptions; } else { #if HAVE_RB_HASH objOptions = rb_Hash(argOptions); #else objOptions = rb_hash_new(); #endif } } VALUE keys = rb_funcall(objOptions, rb_intern("keys"), 0); VALUE ivPrefix = rb_str_new_cstr("@"); long nkey = RARRAY_LEN(keys); for (long i = 0; i < nkey; i++) { VALUE key = rb_ary_entry(keys, i); VALUE val = rb_hash_lookup(objOptions, key); VALUE strKey = rb_String(key); VALUE ivName = rb_str_dup(ivPrefix); rb_str_concat(ivName, strKey); rb_ivar_set(self, rb_intern_str(ivName), val); } return self; } |
Class Method Details
.readable?(argMagic) ⇒ Boolean
画像の先頭バイトからその画像がこのクラスで読み込めるかを判定します.
311 312 313 |
# File 'src/rixmapio.cxx', line 311 static VALUE BaseImageIO_IsReadableStatic(VALUE klass, VALUE argMagic) { return Qfalse; } |
.writable?(argImage) ⇒ Boolean
指定画像がこのクラスで書き込めるかを判定します.
321 322 323 |
# File 'src/rixmapio.cxx', line 321 static VALUE BaseImageIO_IsWritableStatic(VALUE klass, VALUE argImage) { return Qfalse; } |
Instance Method Details
#decode(data, options = {}) ⇒ Rixmap::Image
バイト列から画像を復元します.
復元処理は各フォーマット毎にサブクラスで実装してください.
418 419 420 |
# File 'src/rixmapio.cxx', line 418 static VALUE BaseImageIO_decode(int argc, VALUE* argv, VALUE self) { rb_raise(rb_eNotImpError, "%s#%s is not implemented", rb_obj_classname(self), rb_id2name(rb_frame_this_func())); } |
#encode(image, options = {}) ⇒ String
画像をバイト列へと変換します.
変換処理は各フォーマット毎にサブクラスで実装してください.
403 404 405 |
# File 'src/rixmapio.cxx', line 403 static VALUE BaseImageIO_encode(int argc, VALUE* argv, VALUE self) { rb_raise(rb_eNotImpError, "%s#%s is not implemented", rb_obj_classname(self), rb_id2name(rb_frame_this_func())); } |
#open(path, options = {}) ⇒ Rixmap::Image
指定したパスから画像を読み込みます.
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'src/rixmapio.cxx', line 522 static VALUE BaseImageIO_open(int argc, VALUE* argv, VALUE self) { VALUE argPath, argOptions; rb_scan_args(argc, argv, "11", &argPath, &argOptions); // |
#read(io, options = {}) ⇒ Rixmap::Image
指定されたストリームから画像を読み込みます.
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 |
# File 'src/rixmapio.cxx', line 567 static VALUE BaseImageIO_read(int argc, VALUE* argv, VALUE self) { VALUE argIO, argOptions; rb_scan_args(argc, argv, "11", &argIO, &argOptions); // |
#readable?(argMagic) ⇒ Boolean
画像の先頭バイトからその画像がこのオブジェクトで読み込めるかどうかを判定します.
375 376 377 378 |
# File 'src/rixmapio.cxx', line 375 static VALUE BaseImageIO_isReadable(VALUE self, VALUE argMagic) { VALUE klass = rb_obj_class(self); return rb_funcall(klass, rb_intern("readable?"), 1, argMagic); } |
#save(path, image, options = {}) ⇒ Integer
指定したパスへ画像を書き出します.
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
# File 'src/rixmapio.cxx', line 433 static VALUE BaseImageIO_save(int argc, VALUE* argv, VALUE self) { VALUE argPath, argImage, argOptions; rb_scan_args(argc, argv, "21", &argPath, &argImage, &argOptions); // |
#writable?(argImage) ⇒ Boolean
画像がこのオブジェクトで書き込めるかを判定します.
387 388 389 390 |
# File 'src/rixmapio.cxx', line 387 static VALUE BaseImageIO_isWritable(VALUE self, VALUE argImage) { VALUE klass = rb_obj_class(self); return rb_funcall(klass, rb_intern("writable?"), 1, argImage); } |
#write(io, image, options = {}) ⇒ Integer
指定したストリームへ画像を書き込みます.
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'src/rixmapio.cxx', line 481 static VALUE BaseImageIO_write(int argc, VALUE* argv, VALUE self) { VALUE argIO, argImage, argOptions; rb_scan_args(argc, argv, "21", &argIO, &argImage, &argOptions); // |