following the example in https://github.com/aman-tiwari/dither-thing I have a working project, but I have ofxDither.h and ofxDither.cpp into my projects src dir. which I ‘know’ is not right.
I am pretty sure I have followed the instructions at
openframeworks. cc/learning/01_basics/how_to_add_addon_to_project/
and the faq at ofxaddons pages/howto#install
/home/carl/src/alg/goo/src/ofApp.h:6:10: fatal error: ofxDither.h: No such file or directory
6 | #include “ofxDither.h”
| ^~~~~~~~~~~~~
oops. I made a very fast check of this more recent repo but is not working neither.
The ofxDither.h/.cpp files are missing.
So, I tried the 2 files from the original repo,
both moved into OF/addons/ofxDither/src/
(where the ofxAddons src must be placed)
but I am having some errors too:
note: see declaration of 'ofImage_<unsigned char>::loadImage'
1>f:\openframeworks\addons\ofxdither\ditherexample\src\ofapp.cpp(52): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\ditherexample\src\ofapp.cpp(57): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(71): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(72): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(123): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(124): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(222): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(223): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(345): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(346): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(350): error C2248: 'ofImage_<unsigned char>::bpp': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(644): note: see declaration of 'ofImage_<unsigned char>::bpp'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(352): error C2440: '=': cannot convert from 'ofPixels_<unsigned char>' to 'unsigned char *'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(352): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(360): error C2440: '=': cannot convert from 'ofPixels_<unsigned char>' to 'unsigned char *'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(360): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(365): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(366): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(367): error C2248: 'ofImage_<unsigned char>::bpp': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(644): note: see declaration of 'ofImage_<unsigned char>::bpp'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(357): warning C4996: 'ofImage_<unsigned char>::getPixelsRef': Use getPixels() instead
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(411): note: see declaration of 'ofImage_<unsigned char>::getPixelsRef'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(380): error C2248: 'ofImage_<unsigned char>::width': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(642): note: see declaration of 'ofImage_<unsigned char>::width'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>f:\openframeworks\addons\ofxdither\src\ofxdither.cpp(381): error C2248: 'ofImage_<unsigned char>::height': cannot access protected member declared in class 'ofImage_<unsigned char>'
1>f:\openframeworks\libs\openframeworks\graphics\ofimage.h(643): note: see declaration of 'ofImage_<unsigned char>::height'
1>f:\openframeworks\libs\openframeworks\graphics\ofgraphicsbasetypes.h(21): note: see declaration of 'ofImage_<unsigned char>'
1>Done building project "ditherExample.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========
hey @CarlFK i had a quick look and forked the addon - there were a load of deprecated calls but have fixed the issues and both examples work now (oF v_0.11. on OSX )
you can download or fork the new addon here
to use ofxDither in your own projects (depending on your platform) you can use the project generator to make a new project then select ofxdither from the addons menu (this will just list any addons in your openframeworks/addons/ folder ) then - provided it is being called into your ofApp.h file with the
#include "ofxDither.h"
command - this will then make all the dither capabilities available to your application>>> (screenshot from Xcode on osx showing the addon linked to the project (in the folder structure in the sidebar) and explicitly added in the ofApp.h file)
carl@twist:~/of/of_v0.11.0_linux64gcc6_release/apps/myApps/mySketch$ make
...
/home/carl/of/of_v0.11.0_linux64gcc6_release/apps/myApps/mySketch/src/ofApp.h:4:10: fatal error: ofxDither.h: No such file or directory
4 | #include "ofxDither.h"
| ^~~~~~~~~~~~~
If I understand, there is a command line project generator? posting screen shots of gui steps makes me grumpy
Hi @CarlFK I ran a quick test this morning (i’m on OSX here) and it all works fine - maybe remove and reclone the addon and make a new project - it looks like your project is looking for the addon source files in the wrong folder?
This code works (your mileage may vary) If you cant’ get it working then i’ll run this up when i get to the studio in the week - i have several raspberry Pi running oF in Linux…
ofApp.h
#pragma once
#include "ofMain.h"
#include "ofxDither.h"
class ofApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
ofxDither dither;
ofImage imageIn, imageOut;
};
ofApp.cpp
#include "ofApp.h"
//--------------------------------------------------------------
void ofApp::setup(){
imageIn.load("this-is-fine.jpg");
// choose one from these three
dither.dither_ordered( imageIn, imageOut, DITHER_ORDERED_8x8 );
// dither.dither_floyd_steinberg( imageIn, imageOut );
// dither.dither_atkinson( imageIn, imageOut );
}
//--------------------------------------------------------------
void ofApp::update(){
}
//--------------------------------------------------------------
void ofApp::draw(){
imageIn.draw(0,0);
imageOut.draw(0, imageOut.getHeight());
}
@danb,
btw. I tested here on Windows/VS2017 and ditherShaderExample works.
But the other ditherExample it compiles but has (a kind of random) crashes. The example crashes here:
ofxDither.cpp
ditherExample_debug.exe!ofxDither::dither_ordered(ofImage_ & imageIn, ofImage_ & imageOut, int mapSize) Line 103 C++
@moebiussurfing thanks for checking it out and the confirmation - the ditherexample seems stable on OSX but i’ll do some more digging when i get time - I did little to the code other than update now-deprecated calls but will see what I can find…
whoops - good catch. I am sure my problem is something silly like: you cloned into the wrong directory.
and yes, this is my problem: “it looks like your project is looking for the addon source files in the wrong folder?” or as far as I can tell, it isn’t looking for addon source anywhere, it is only looking for the default libs.
in a nutshell, I say:
#include "ofxDither.h"
and the compiler says …
ok, now it is finding that file.
I am not sure how replacing that files in addons dir helped the compiler find them as I didn’t change anything in my project files.
I moved the extra ofxDitther files out of my project dir, my app runs just as it did before, and now I have less files to worry about.
is it working now ?
Good news - let me know if you see the random crashes that @moebiussurfing mentioned - i didn’t write the addon but if i can get any more info I’ll see if i can track down the bug and fix it…