Efficient xor cursor ... in color?

Julia can xor a cursor image with an image when both images are gray, producing the following image with the following code:

trash3

	img = Array{N0f8}(reshape(range(0,stop=1,length=10^4), 100, 100))
	imgx = zeros(N0f8, 21, 21)
	imgx[10:12,:] .= 1.
	imgx[:,10:12] .= 1.
	
	img_num = reinterpret(UInt8, img)
	imgx_num = reinterpret(UInt8, imgx)
	img_num[10:30,70:90] = xor.(
		img_num[10:30,70:90],
		imgx_num)

	save("trash3.png", img)

However, I don’t understand how to get Julia to access the UInt8 color fields for the color version of that xor operation. My first attempt was reinterpreting N0f8 from the channelview reinterpretation of the loaded image. Apparently, two layers of reinterpret cause problems with accessing ranges of pixels:

julia> img_map = load("bok.png"); # Array{RGBA{N0f8},2}

julia> img_map_num = channelview(img_map); # 4×3372×6000 reinterpret(reshape, N0f8, ::Array{RGBA{N0f8},2})

julia> img_map_num2 = reinterpret(UInt8, img_map_num); # 4×3372×6000 reinterpret(UInt8, reinterpret(reshape, N0f8, ::Array{RGBA{N0f8},2}))

julia> display(img_map_num2[1,1:10,1:10])
ERROR: MethodError: no method matching _maybe_reshape(::Base.IndexSCartesian2{4}, ::Base.ReinterpretArray{UInt8, 3, N0f8, Base.ReinterpretArray{N0f8, 3, RGBA{N0f8}, Matrix{RGBA{N0f8}}, true}, false}, ::Int64, ::UnitRange{Int64}, ::UnitRange{Int64})
Closest candidates are:
  _maybe_reshape(::Base.IndexSCartesian2, ::Base.ReinterpretArray{T, N, S, A, true} where {T, N, S, A<:(AbstractArray{S})}, ::Any...) at C:\tool\Julia-1.7.3\share\julia\base\reinterpretarray.jl:255
  _maybe_reshape(::IndexLinear, ::AbstractArray, ::Any...) at C:\tool\Julia-1.7.3\share\julia\base\multidimensional.jl:842
  _maybe_reshape(::IndexCartesian, ::AbstractArray, ::Any...) at C:\tool\Julia-1.7.3\share\julia\base\multidimensional.jl:844
  ...
Stacktrace:
 [1] _getindex
   @ .\multidimensional.jl:839 [inlined]
 [2] getindex(::Base.ReinterpretArray{UInt8, 3, N0f8, Base.ReinterpretArray{N0f8, 3, RGBA{N0f8}, Matrix{RGBA{N0f8}}, true}, false}, ::Int64, ::UnitRange{Int64}, ::UnitRange{Int64})
   @ Base .\abstractarray.jl:1218
 [3] top-level scope
   @ REPL[301]:1

And my attempt at getting access to the UInt8 fields in a single reinterpret also doesn’t work:

julia> imgx = load("iconArrow101.png")
101×101 Array{RGB{N0f8},2} with eltype RGB{N0f8}:
 RGB{N0f8}(0.0,0.157,1.0)  RGB{N0f8}(0.0,0.157,1.0)  …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.157,1.0)  RGB{N0f8}(0.0,0.157,1.0)     RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.157,1.0)     RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.157,1.0)     RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)    …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)    …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 ⋮                                                   ⋱                            ⋮
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)    …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)    …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.157,1.0)  RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.157,1.0)  RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.157,1.0)  RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)       RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)
 RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)    …  RGB{N0f8}(0.0,0.0,0.0)    RGB{N0f8}(0.0,0.0,0.0)

julia> imgx_num = reinterpret(reshape, Array{RGB{UInt8},2}, imgx)
ERROR: TypeError: in RGB, in T, expected T<:Union{AbstractFloat, FixedPoint}, got Type{UInt8}
Stacktrace:
 [1] top-level scope
   @ REPL[304]:1

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:

	# 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)