Hi Matt,

What i want to do is get the r,g,b,a values individually, modify them and
then set them.

Your example was good, but is not extracting the r,g,b,a values
individually (which come out as uint32's), and then say when i change them
and set them again, it complains that it only wants uint8's.

Essentially, i want to be able to tweak the r,g,b,a values without having
to do converts from uint32's to uint8's as information is being lost there.

cheers,

simran.



On Mon, Jul 4, 2016 at 9:58 AM, Matt Harden <matt.har...@gmail.com> wrote:

> I can't tell exactly what the problem is from your example, but does this
> help?
>
> https://play.golang.org/p/AF8UjkG4Ao
>
> On Sun, Jul 3, 2016 at 4:40 PM simran <sim...@dn.gs> wrote:
>
>> Hi Constantin,
>>
>> Where i seen the uint8 being defined is at:
>> https://golang.org/pkg/image/color/#RGBA
>>
>> Although the there is a method RGBA() which returns r,g,b,a in uint32 the
>> struct is only uint8's and so i suspect has to be initialised as such.
>>
>> What i'm finding annoying is that the following fails:
>>
>> *package main*
>>
>> *import "image"*
>> *import "image/color"*
>>
>> *func main() {*
>> * m := image.NewRGBA(image.Rect(0, 0, 1, 1))*
>> * x, y := 0, 0*
>> * colour := m.At(x, y)*
>> * r, g, b, a := colour.RGBA()*
>>
>> * newColour := color.RGBA{r, g, b, a}*
>> * m.SetRGBA(x, y, newColour)*
>> *}*
>>
>> *prog.go:12: cannot use r (type uint32) as type uint8 in field value
>> prog.go:12: cannot use g (type uint32) as type uint8 in field value
>> prog.go:12: cannot use b (type uint32) as type uint8 in field value
>> prog.go:12: cannot use a (type uint32) as type uint8 in field value*
>>
>>
>> Link to go playground for the above: https://play.golang.org/p/ToV1TH1NAr
>>
>> Really want to this colour problem, any help appreciated :)
>>
>> cheers,
>>
>> simran.
>>
>> On Mon, Jul 4, 2016 at 2:30 AM, Constantin Konstantinidis <
>> constantinkonstantini...@gmail.com> wrote:
>>
>>> I cannot answer about the matrix library but the package is consistently
>>> talking about int and not uint8
>>> If you look at the specification
>>> https://golang.org/pkg/image/#RGBA.SetRGBA
>>> You can impose 64bit which is not your pupose but apparently truncating
>>> int is not mandatory.
>>> Can you indicate where you found it ?
>>>
>>> Thanks
>>>
>>>
>>> On Sunday, July 3, 2016 at 6:07:34 PM UTC+2, simran g wrote:
>>>>
>>>> Hi All,
>>>>
>>>> Could someone please point me to a good matrix library for Go (i'm sure
>>>> something exists, although i can't seem to find it!).
>>>>
>>>> Am hoping to do some image manipulation for which being able to work
>>>> with matrices would be great.
>>>>
>>>> Have written simple helper stuff for images (i used to find myself
>>>> doing the same a few time, so just put it in a library) (
>>>> https://github.com/simran91/monkeysee ).
>>>>
>>>> On another note, if you do look at the library above, you'll notice
>>>> that my source image at (
>>>> https://github.com/simran91/monkeysee/blob/master/samples/rgb.png) and
>>>> destination image at (
>>>> https://github.com/simran91/monkeysee/blob/master/samples/rgb-png-to-png-mod-SwapRGBtoGBR-autogenerated.png)
>>>> have colours messed up.
>>>>
>>>> The colours were meant to have swapped, but the Red has gone into being
>>>> an Pink.
>>>>
>>>> This i suspect is because when we call colour.RGBA() we get uint32's,
>>>> but when we set the colour using color.RGBA{r, g, b, a} they r,g,b,a have
>>>> to be uint8's
>>>> (File where i have to do the conversion:
>>>> https://github.com/simran91/monkeysee/blob/master/mimage/rgba-matrix-to-raw-data.go
>>>> )
>>>>
>>>> Has anyone else come across this? I suspect there is a way to load up
>>>> color.RGBA and give it uint32's? Would appreciate any pointers in that
>>>> regard as well.
>>>>
>>>> thanks,
>>>>
>>>> simran.
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "golang-nuts" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to golang-nuts+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to