purple-fringe icon indicating copy to clipboard operation
purple-fringe copied to clipboard

Does this have a c/c++ version?

Open Dorothy-2016 opened this issue 4 years ago • 3 comments

Thanks for your nice work first! and I was dealing with the same problem of purple fringe, and I tried your method, it works well most times, except when my picture was big and there's purple things in the picture, it will change the color sometimes. also I want to solve the green purple fringe, so I want try somethings based on your method maybe, but I nevel use OCaml, I was wondering if there's a c/c++ version of your method? Hoping for your reply!

Dorothy-2016 avatar Nov 16 '20 02:11 Dorothy-2016

Hi @Dorothy-2016! Unfortunately I'm not aware of a C or C++ implementation. The only other implementation I know of is the one linked in the readme (https://github.com/dtschump/gmic-community/blob/master/include/stanislav_paskalev.gmic). I don't know if it helps.

The OCaml implementation is pretty bare-bones and only uses imperative features of ocaml. It means you should be able to translate most of the code directly using C arrays or equivalent.

  • ocaml arrays are mutable like this: a.(i) <- 42.
  • individual mutable values are put in a reference cell. ref 42 is a call of the function ref to initialize a ref with the value 42. The value can be changed with := e.g. x := 17. Reading the current value is done with !x (nothing to do with a NOT operator).
  • arithmetic operators +. -. with a dot work only on ocaml floats (= C doubles), whereas the usual + - etc. work only on ints.
  • converting an int to a float must be done explicitly with the float function e.g. float 42 gives 42.0.
  • there's no return. The last expression evaluated by a function is what's returned.

This should cover most of the ocaml oddities :-)

mjambon avatar Nov 16 '20 07:11 mjambon

OK, I will try it and thanks very much for your kindly reply!

Dorothy-2016 avatar Nov 16 '20 09:11 Dorothy-2016

@Dorothy-2016 hey,dude.Have you ever find an implementation base on c++ or python? if yes, can you share the link. thx alot

ChuanjunLAN avatar Mar 15 '21 08:03 ChuanjunLAN