123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- class IUP_IMAGE
- inherit
- IUP_WIDGET
- IUP_WIDGET_INTERNALS
- IUP_WIDGET_BGCOLOR
- create {ANY}
- image,
- image_rgb,
- image_rgba,
- load
- create {CD_CLIENT_IMAGES}
- with_internal
- feature {ANY}
- image (a_width, a_height: INTEGER; a_pixels: ARRAY[INTEGER])
-
-
-
- require
- a_width_not_negative: a_width >= 0
- a_height_not_negative: a_height >= 0
- a_values_not_void: a_pixels /= Void
- consistent_size: a_width * a_height = a_pixels.count
- local
- a_image: POINTER
- do
- a_image := int_image(a_width, a_height, convert_array(a_pixels))
- if a_image /= default_pointer then
- set_widget(a_image)
- end
- end
- image_rgb (a_width, a_height: INTEGER; a_pixels: ARRAY[TUPLE[INTEGER, INTEGER, INTEGER]])
-
-
-
- require
- a_width_not_negative: a_width >= 0
- a_height_not_negative: a_height >= 0
- a_values_not_void: a_pixels /= Void
- consistent_size: a_width * a_height = a_pixels.count
- local
- a_image: POINTER
- do
- a_image := int_image_rgb(a_width, a_height,
- convert_rgb_array(a_pixels))
- if a_image /= default_pointer then
- set_widget(a_image)
- end
- end
- image_rgba (a_width, a_height: INTEGER; a_pixels: ARRAY[TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]])
-
-
-
- require
- a_width_not_negative: a_width >= 0
- a_height_not_negative: a_height >= 0
- a_values_not_void: a_pixels /= Void
- consistent_size: a_width * a_height = a_pixels.count
- local
- a_image: POINTER
- do
- a_image := int_image_rgba(a_width, a_height,
- convert_rgba_array(a_pixels))
- if a_image /= default_pointer then
- set_widget(a_image)
- end
- end
- load (file_name: STRING)
-
-
- local
- a_image: POINTER
- do
- a_image := int_load(get_pointer(file_name.to_c))
- if a_image /= default_pointer then
- set_widget(a_image)
- end
- end
- was_created: BOOLEAN
-
-
- do
- if widget /= default_pointer then
- Result := True
- else
- Result := False
- end
- end
- get_error: STRING
-
-
-
- do
- if widget /= default_pointer then
- Result := "NO_ERROR"
- else
- Result := iup_open.get_global_attribute("IUPIM_LASTERROR")
- end
- end
-
- save (file_name, format: STRING): STRING
-
-
-
-
-
-
- local
- i: INTEGER
- do
- i := int_save(widget, get_pointer(file_name.to_c), get_pointer(format.to_c))
- if not i.is_equal(0) then
- Result := "NO_ERROR"
- else
- Result := iup_open.get_global_attribute("IUPIM_LASTERROR")
- end
- end
-
- set_color_at_index (rgb: STRING; index: INTEGER)
-
-
-
-
-
-
-
-
-
-
-
- require
- index >= 0
- index <= 255
- is_valid_rgb_string(rgb)
- do
- iup_open.set_attribute(Current, index.out, rgb)
- end
- set_auto_scale (value: REAL_32)
-
-
-
- do
- iup_open.set_attribute(Current, "AUTOSCALE", value.out)
- end
- get_bpp: INTEGER
-
-
-
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "BPP")
- if str.is_integer then
- Result := str.to_integer
- end
- end
-
- get_channels: INTEGER
-
-
-
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "CHANNELS")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- get_height: INTEGER
-
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "HEIGHT")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- set_hot_spot (x, y: INTEGER)
-
-
-
- require
- x >= 0
- y >= 0
- local
- v: STRING
- do
- v := x.out
- v.append_string(":")
- v.append_string(y.out)
- iup_open.set_attribute(Current, "HOTSPOT", v)
- end
- get_rastersize: TUPLE[INTEGER, INTEGER]
-
- local
- size: STRING
- do
- size := iup_open.get_attribute(Current, "RASTERSIZE")
- Result := components_of_size(size)
- end
-
- resize_to (width, height: INTEGER)
-
-
-
- require
- width > 0
- height > 0
- local
- v: STRING
- do
- v := width.out
- v.append_string("x")
- v.append_string(height.out)
- iup_open.set_attribute(Current, "RESIZE", v)
- end
- get_width: INTEGER
-
- local
- str: STRING
- do
- str := iup_open.get_attribute(Current, "WIDTH")
- if str.is_integer then
- Result := str.to_integer
- end
- end
- feature {CD_CLIENT_IMAGES}
- with_internal (a_image: POINTER)
- do
- set_widget(a_image)
- end
- get_wid: POINTER
-
- do
- Result := int_get_attribute(widget, get_pointer(("WID").to_c))
- end
- feature {NONE}
-
- int_image (width, height: INTEGER; pixels: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupImage ($width, $height, $pixels);"
- end
- int_image_rgb (width, height: INTEGER; pixels: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupImageRGB ($width, $height, $pixels);"
- end
- int_image_rgba (width, height: INTEGER; pixels: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupImageRGBA ($width, $height, $pixels);"
- end
- int_load(file_name: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupLoadImage ($file_name);"
- end
- int_save(wgt, file_name, format: POINTER): INTEGER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupSaveImage ($wgt, $file_name, $format);"
- end
- int_get_attribute (wgt, name: POINTER): POINTER
- external
- "C inline use %"eiffel-iup.h%""
- alias
- "return IupGetAttribute ($wgt, $name);"
- end
-
- convert_array (matrix: ARRAY[INTEGER]): POINTER
- local
- i, v: INTEGER;
- arg: ARRAY[CHARACTER_8]
- do
- create arg.make_filled(' ', 1, matrix.count + 1)
- i := 0
-
- across
- matrix as ic
- loop
- i := i + 1
- v := ic.item
- arg.put(v.to_character_8, i)
- end
-
- Result := get_pointer(arg.to_c)
- end
- convert_rgb_array (matrix: ARRAY[TUPLE[INTEGER, INTEGER, INTEGER]]): POINTER
- local
- i: INTEGER;
- arg: ARRAY[CHARACTER_8]
- v: TUPLE[INTEGER, INTEGER, INTEGER]
- do
- create arg.make_filled(' ', 1, matrix.count + 1)
- i := 0
-
- across
- matrix as ic
- loop
- i := i + 1
- v := ic.item
- arg.put(v.integer_32_item(1).to_character_8, i)
- i := i + 1
- arg.put(v.integer_32_item(2).to_character_8, i)
- i := i + 1
- arg.put(v.integer_32_item(3).to_character_8, i)
- end
-
- Result := get_pointer(arg.to_c)
- end
- convert_rgba_array (matrix: ARRAY[TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]]): POINTER
- local
- i: INTEGER;
- arg: ARRAY[CHARACTER_8]
- v: TUPLE[INTEGER, INTEGER, INTEGER, INTEGER]
- do
- create arg.make_filled(' ', 1, matrix.count + 1)
- i := 0
-
- across
- matrix as ic
- loop
- i := i + 1
- v := ic.item
- arg.put(v.integer_32_item(1).to_character_8, i)
- i := i + 1
- arg.put(v.integer_32_item(2).to_character_8, i)
- i := i + 1
- arg.put(v.integer_32_item(3).to_character_8, i)
- i := i + 1
- arg.put(v.integer_32_item(4).to_character_8, i)
- end
-
- Result := get_pointer(arg.to_c)
- end
- end
|