Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

196 Neutral

About welOhim

  • Rank
  1.   thanx, Indeed i was clueless about some theories. Particularly about this     Though not as bad as you wrote. Actually i fully understood Ashaman73's code, bit shifting and filtering the bits to separate rgba channels ...  But i was naive about the getPixel(x, y) return value, and misunderstood its use   the reason i used those values literally (now i know wrongly) was that in eclipse  .getPixel(x, y) states     int android.graphics.Bitmap.getPixel(int x, int y) Returns the Color at the specified location. Throws an exception if x or y are out of bounds (negative or >= to the width or height respectively). The returned color is a non-premultiplied ARGB value. Parameters: x The x coordinate (0...width-1) of the pixel to return y The y coordinate (0...height-1) of the pixel to return Returns: The argb Color at the specified coordinate Throws: IllegalArgumentException - if x, y exceed the bitmap's bounds   The second line says   Returns the Color at the specified location.  My naiveness started by misunderstanding this line (ie the returned integer)
  2. -   If it makes any difference, the code is in Java not c++    Second if  aBitmapObject.getpixel( x, y )   returns  a negative value, who am i to decide to change it to an arbitrary unsigned  value which the compiler would then interpret to represent a different colour, that would be a meaningless value   Which is why i strongly believe Ashaman73's code should be an ideal solution as it avoids overflow,  while still maintaining the relative colour space mapping as in the compiler interpretation. It is merely scaled down.  
  3.   Makes very good sense. I will try this, thanx
  4. On android, i am capturing images doing some (bitmap) analysis, I scan image (iterate through pixel by pixel) examining each pixel colour.   I needed to find the average colour (primary school maths), But Something wasn't right ,    Initially i had pondered:-  as i begin to sum up the colours (a typical value is -8287599) and for a sub patch of 400X300 the sum could be as big as  -994511880000 or much higher. These values are higher than an integer could handle so i was expecting overflow error when i run it.   But i didn't get any exception, instead the values were plain wrong. But you will only know they are wrong if you examine very closely. These values could be negative or positive, Black-ish pixels tend to be large negative integers while white-ish pixels tend to be large positive integers.     To pin down the wrongness, i snapped while putting the camera in pitch-dark environment (covering the camera lens or place in a black box ) and snapped   Then i wrote a very simple code to get the largest pixel colour, smallest pixel colour and the average pixel colour.     int  biggestDark2 = -990466330, biggestWhite2 = 990466330; float avr = 0.0f; . . . if ( copyOfBM != null ){ int y=0, x=0, sum=0,  cnt=0; for(y=0; y<rHeight; y++){ for( x=0; x<rWidth; x++ ){ if( !(((y>=lH) && (y<uH)) && ((x>=lW) && (x<uW))) ){ } else if( (((x>=lW) && (x<uW))) && ((y>=lH) && (y<uH)) ){ if( biggestDark2 < copyOfBM.getPixel(x, y) ){ biggestDark2 = copyOfBM.getPixel(x, y); } if( biggestWhite2 > copyOfBM.getPixel(x, y) ){ biggestWhite2 = copyOfBM.getPixel(x, y); } sum = sum + copyOfBM.getPixel(x, y); cnt = cnt + 1; } } } avr = (float)sum / (float)cnt; Log.v(tag, "avr "+avr); Log.v(tag, "biggestWhite2 "+biggestWhite2+" *=**=* biggestDark2 "+biggestDark2); Log.v(tag, " "); The output confirmed that the average was completely wrong was:   --------- beginning of /dev/log/system   V/DEAS   (18171): avr             9671.571   V/DEAS   (18171): biggestWhite2    -16777216  *=**=*   biggestDark2   -16645630   V/DEAS   (18171):        which doesn't make any sense, since the lowest and highest values are large negatives but the average is a large positive (which shouldn't exist.)   Was this caused by integer overflow?   How do i avoid this overflow problem (if it is overflow) so to obtain the correct average colour? Thanks 
  5. I'm not one to panic at every security risks messages, but my phone antivirus software has persistently stuck to a message:   1 Problem to resolve: USB debugging: when USB debugging is enabled intruders can access your data despite PIN protection   In other words my phone is vulnerable because i enabled USB debugging   As an app developer on android i have to constantly leave USB debugging as enabled. And so i ignored for a long while, until i started having "superuser permission has been granted"  pop-ups regularly    So the question is:  Is the risk of enabling USB debugging real?   If it is, what options do app developers have to eliminate (or minimise) the risk, since USB debugging needs to be enabled anyway?
  6. now that you mentioned it, i've wondering what the benefits of using C++ JNI/NDK for Android development is since Google discourage it.  https://developer.android.com/tools/sdk/ndk/index.html maybe to extend  a library that only exist in c++? since Google says it can't be because of better perfomance     EDIT: sorry my mistake i missed reading this part since Google later contradicted itself,    Typical good candidates for the NDK are CPU-intensive workloads such as game engines, signal processing, physics simulation, and so on. When examining whether or not you should develop in native code, think about your requirements and see if the Android framework APIs provide the functionality that you need.
  7. welOhim

    Bitmap graphics pixels scanning

     this should do it Many Thanks for the links,  
  8. welOhim

    Bitmap graphics pixels scanning

    Thanks for the hint.   I have been looking at the link, and how to use AGAL helper library and the learning curve seem huge   I know you mention AGAL.convolve(output, sample, texture, uv, offset, matrix)+    but struggling to see how to use it to achieve the aim directly.    Obviously you used in C++, Can it the library be used in Java environment? Thanks
  9. Hi   I have a simple algorithm in mind for this game:- activate "x" animation or gameplay when letter "y" is recognised by the scanning phone camera image (all done in code) So what you play varies and depends on what letter the camera scans. This sort of thing (in different forms) is common in augmented reality games    But my first step to doing this ran into a problem that i can't explain    To start with, i started with a simple enough test algorithm:    scan Bitmap pixel by pixel (image of A4 paper - which has pen marks on it),  if a pixel's color is black paint it red otherwise put white colour on the pixel   My cut-off for black is flexible and changeable. I experimented a lot  I came up with a form of grey :  int colorConst2  = ((Color.GRAY +  Color.GRAY +  Color.GRAY + Color.GRAY)/4)  +  700000;   This is so that a dim lighting or mild shadows don't get translated as a black   But whatever the cut-off  i choose there are lots of pixels on the outer edges that get coloured red (for black pixels) even though they are white (see images) If i lower the cut-off so those rouge pixels don't get picked up, then some of the real black marks on the inside begin to fade off (not picked as black)   While human still recognised the letters, the rouge pixels messes up the program's letter recognition algorithm for variable animation and gameplay   Initially I thought it was the phone camera settings, after trying all settings available, i came to the conclusions it is a graphics algorithm issue Probably something i need to take into account while checking the pixels   I am mystified, hoping someone knows what it is  
  10. Solved!!!!   In case anyone else encounters the same problem, solution:-   It turns out that when i added the code below with //NEW  and removed                        setEGLContextClientVersion(2);    (this line killed off the renderer draw)  then it worked!!!   I also had to create MyGLSurfaceView class and make the adjustments in the xml file  Resources res = this.getResources(); //NEW XmlPullParser parser = res.getXml(R.layout.buttontogl2); //NEW AttributeSet attributes = Xml.asAttributeSet(parser); //NEW glView = new MyGLSurfaceView(this, attributes); //NEW setContentView(R.layout.buttontogl2); glView = (MyGLSurfaceView) findViewById(R.id.glSurfaceViewID);
  11.     Ah, I think my mistake is i thought GLSurfaceView is a view object or the view object to use. Now i'm at my wits end. Please with a look at the code would you be able to advice how i can create the appropriate view object?   how do i adjust the xml file?    Many thanks <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id= "@+id/linearlayout1"> <com.example.xtragames.Convert.GLSurfaceView android:id="@+id/glSurfaceViewID" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.23" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout>
  12.     Sorry for late response, was working.   Thanks for the observation, I have now replaced    com.example.xtragames.Convert.MyGLRenderer    with com.example.xtragames.Convert.GLSurfaceView   When i run now, it still forced closed as before (nothing on logcat).   (posting renderer class seem to have added more confusion)   Thanks
  13. Hello, (EDIT; solved see 5th(or 6th) reply)   Does anyone have a hint on how to put UI Button in XML to GLSurfaceView (OpenGL ES)?   Or any clue why the code below attempting to do that fails?   Many thanks public class Convert extends Activity { private GLSurfaceView glView; public int n = 7, t=0; ObjectsDataStructure sketchDataStructure; Button button; // Call back when the activity is started, to initialize the view @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //** getWindow().setFormat(PixelFormat.TRANSLUCENT); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); glView = new GLSurfaceView(this); // Allocate a GLSurfaceView glView.setRenderer(new MyGLRenderer(this, n, t )); // Use a custom renderer // this.setContentView(glView); // This activity sets to GLSurfaceView setContentView(R.layout.buttontogl2); glView = (GLSurfaceView) findViewById(R.id.glSurfaceViewID); // button = (Button)findViewById(R.id.button1); this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } public Convert (){ } @Override protected void onPause() { super.onPause(); glView.onPause(); } // Call back after onPause() @Override protected void onResume() { super.onResume(); glView.onResume(); } } <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id= "@+id/linearlayout1"> <com.example.xtragames.Convert.MyGLRenderer android:id="@+id/glSurfaceViewID" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.23" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </LinearLayout>
  14. funny my experience (i'm by no means an expert but in my own little way) is the other way round.   for me my attempt with android studio was a nightmare,   Graddle burns up cpu contantly A Configuration dialog pops up... whatever options i choose, when i click ok it says error the spawn-web in the project explorer goes on and on Loading and running sample projects comes up blank I was wondering if i was supposed the read a huge user-manual before using android studio    But with eclipse, almost no problems, except that the logcat output disappears within 20-30mins 
  15. welOhim


        Yet more!! I hope i'm not sounding like an alarmist but i am posting this Just in case the urls below will help hunt down the source of the virus attack   I love this place, this forum's interactions and resource is invaluable, but if part of the of the times that people visit here there is a virus alert, the reputation and "brand" of this place gets damaged  
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!