# wxRuby error: Image file is not of type 9

**URL:** <https://www.ruby-forum.com/t/wxruby-error-image-file-is-not-of-type-9/151201>\
**Category:** wxRuby\
**Created:** [October 18, 2008, 2:01am UTC](https://www.ruby-forum.com/t/wxruby-error-image-file-is-not-of-type-9/151201 "2008-10-18T02:01:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [October 18, 2008, 2:01am UTC](https://www.ruby-forum.com/t/wxruby-error-image-file-is-not-of-type-9/151201/1 "2008-10-18T02:01:25Z")

</div>

Hello

I’m having problems with rhis error, I couldnt found the solution (or  
even mention) on the internet

I’m doing a toolbar, called @toolBarPrincipal, then I add the tool,and  
finally the #realize() method.

This error happens when openig the file (on windows, linux ran pretty  
well)  
I still can work with the program but the icon (or bitmap or whatever)  
doesnt shows.

The Code is:

@toolBarPrincipal=create\_tool\_bar(TB\_HORIZONTAL | NO\_BORDER | TB\_FLAT |  
TB\_TEXT )  
@toolBarPrincipal.add\_tool(-1, ‘Bonzai2’,  
Bitmap.new(“C:/rubyCode/icons/bonsai.ico”))  
@toolBarPrincipal.realize()

also tryed:  
@toolBarPrincipal.add\_tool(-1, ‘Bonzai2’,  
Bitmap.new(“C:/rubyCode/icons/bonsai.bmp”))

Renaming the file or savin as from mspaint, but no good.

Does anyone knows how to solve it?

Thanks

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [October 18, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/wxruby-error-image-file-is-not-of-type-9/151201/2 "2008-10-18T16:47:44Z")

</div>

Omar H. wrote:

> @toolBarPrincipal=create\_tool\_bar(TB\_HORIZONTAL | NO\_BORDER | TB\_FLAT |  
> TB\_TEXT )  
> @toolBarPrincipal.add\_tool(-1, ‘Bonzai2’,  
> Bitmap.new(“C:/rubyCode/icons/bonsai.ico”))

Try adding the type argument to tell wxRuby what type of image file  
you’re loading from

Wx::Bitmap.new(“/path/to/icon.ico”, Wx::BITMAP\_TYPE\_ICO)

See the Wx::Bitmap documentation for a list of supported types. For  
cross-platform use, I’d recommend using PNG over ICO or BMP

hth  
alex

---

<div class="post-metadata">

**Author:** ![ramo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/f17d59/32.png) [@ramo](https://www.ruby-forum.com/u/ramo)\
**Post date:** [November 12, 2008, 1:35am UTC](https://www.ruby-forum.com/t/wxruby-error-image-file-is-not-of-type-9/151201/3 "2008-11-12T01:35:38Z")

</div>

> Try adding the type argument to tell wxRuby what type of image file  
> you’re loading from
> 
> Wx::Bitmap.new(“/path/to/icon.ico”, Wx::BITMAP\_TYPE\_ICO)
> 
> See the Wx::Bitmap documentation for a list of supported types. For  
> cross-platform use, I’d recommend using PNG over ICO or BMP
> 
> hth  
> alex

Thanks, it’s working fine.
