# Efficient xor cursor ... in color?

**URL:** <https://discourse.julialang.org/t/efficient-xor-cursor-in-color/82644>\
**Category:** General Usage\
**Tags:** images, array, type\
**Created:** [June 12, 2022, 7:42pm UTC](https://discourse.julialang.org/t/efficient-xor-cursor-in-color/82644 "2022-06-12T19:42:00Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![g2g](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@g2g](https://discourse.julialang.org/u/g2g)\
**Post date:** [June 13, 2022, 5:19pm UTC](https://discourse.julialang.org/t/efficient-xor-cursor-in-color/82644/2 "2022-06-13T17:19:39Z")

</div>

My mistake. Julia makes the UInt8 data available in color images. I was just indexing it incorrectly. The following color plot with a golden color xor cursor was generated with the following code:

 ![trash4](https://global.discourse-cdn.com/julialang/original/3X/d/4/d4bca4e1c848160df9a4a2fa94211b51e3e257b1.jpeg)

```julia
	# load map and arrow
	img_map = load("bok.png"); # Array{RGBA{N0f8},2}
	img_map_num = reinterpret(UInt8, img_map);
	img_map_chan = reshape(img_map_num, (4,:))
	img_arrow = load("iconArrow301.png") # # Array{RGBA{N0f8},2}
	img_arrow_num = reinterpret(UInt8, img_arrow)
	img_arrow_chan = reshape(img_arrow_num, (4,:))
	nMap = size(img_map,1)
	nArrow = size(img_arrow,1)
	
	# draw arrow in map
	x0 = 949
	y0 = 1845
	for iColorChan = 1:3
		img_map_color = reshape(img_map_chan[iColorChan,:], (nMap,:))
		img_arrow_color = reshape(img_arrow_chan[iColorChan,:], (nArrow,:))
		img_map_color[y0:y0+nArrow-1,x0:x0+nArrow-1] .= xor.(
			img_map_color[y0:y0+nArrow-1,x0:x0+nArrow-1], 
			img_arrow_color)
		img_map_chan[iColorChan,:] = img_map_color[:]'
	end
	img_map_num = reshape(img_map_chan, (nMap*4,:))
	save("trash4.png", img_map)

```

---

_[View the full topic](https://discourse.julialang.org/t/efficient-xor-cursor-in-color/82644)._
