This assignment is asking for getLuminance to "return the luminance of a Pixel as the average of the three color channel values" and I think i have it set up right, but for some reason in the line   while ( sunflower.hasNext() ) {   'hasNext' is giving an error that says "Dereferencing possible null pointer" I have no idea what is going on.  the line   n = (int) TARGET/getLuminance(p);   is also giving an error that is requiring a Picture and a Pixel, but getLuminance only requires a pixel so I'm not sure what's happening there as well.      public Luminance() {     Picture  sunflower;        // picture to be modified     sunflower = new Picture();     display = new PictureDisplayer(sunflower);     display.waitForUser();     setLuminance(sunflower, 127.5);     display.close();     System.exit(0); }      private int getLuminance (Pixel p) {        Picture sunflower = null;        int   r;  // red value of pixel        int   g;  // green value of pixel        int   b;  // blue value of pixel        int   v = 0;  // average           while ( sunflower.hasNext() ) {              p = sunflower.next();              r = p.getRed();              g = p.getGreen();              b = p.getBlue();              v = (r + g + b)/3;              clip (v);      }     return v; }    private int clip(int val){     if (val &lt;=255){         return val;     }     else {         return 255;     } }  private void setLuminance(Picture sunflower, double TARGET) {     Pixel p;     int   r;  // red value of pixel     int   g;  // green value of pixel     int   b;  // blue value of pixel     int   n;         //getLuminance(sunflower);     while ( sunflower.hasNext() ) {         p = sunflower.next();         r = p.getRed();          g = p.getGreen();          b = p.getBlue();          n = (int) TARGET/getLuminance(p);          p.setRed(n*r);          p.setGreen(n*g);          p.setBlue(n*b);           } }  /**  * @param args the command line arguments  */ public static void main(String[] args) {Luminance r = new Luminance();     // TODO code application logic here }
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
12184
I'm trying to get an understanding of what the the java keyword this actually does. I've been reading Sun's documentation but I'm still fuzzy on what this actually does.
27753
I am trying to make a computer monitor. This means I have to have an image texture for the screen. My image texture is currently connected to an Emission BSDF shader. Unfortunately, when the emission is bright enough to emit light, the image is white-washed. I tried adding a Brightness/contrast node to the image before pushing it into the Emission BSDF, but it seems to directly counter the Emission's strength.  The desired light level   The desired image brightness
84402
I am programming a graphics engine for an old game. The game uses a BSP geometry which I have rendering perfectly. For it's lights however, it simply has light instances with the standard x, y, z, rgba, brightness, type. Now I know that OpenGL has an 8 light limit. How should I go about handling multiple lights.  I am learning per fragment light just to have the concepts under my belt. I know per pixel lighting is the standard and I will eventually move there, just want to learn how to get this concept put in play as well.  I assume I will just calculate which lights are the closest and render those 8. Does anyone have any other ideas?
77421
Is there a cheap way to get the dimensions of an image (jpg, png, ...)? Preferably, I would like to achieve this using only the standard class library (because of hosting restrictions). I know that it should be relatively easy to read the image header and parse it myself, but it seems that something like this should be already there. Also, I’ve verified that the following piece of code reads the entire image (which I don’t want):  using System; using System.Drawing;  namespace Test {     class Program     {         static void Main(string[] args)         {             Image img = new Bitmap("test.png");             System.Console.WriteLine(img.Width + " x " + img.Height);         }     } }
119
I feel I am nearing completion of the tutorial but am still having gaps in knowledge on how to render light properly. 2.92.0 blender file:  Overview layout:  Lamp:  128 sample before denoise:  128 sample after denoise:  1024 sample 1080p 100% render before denoise:  1024 sample 1080p 100% render after denoise:  I've been trying different Light paths, but I honestly don't understand the extent of how they interact with each other. I haven't seen any example of what those numbers should be in the tutorial either, if someone knows please let me know.  but it is now again a little bit too opaque, dunno when that happened. :D Not too sure what I am missing out so any suggestions would be lovely! Thank you in advance
4029
uint color;  bool parsedhex = uint.TryParse(TextBox1.Text, out color);  //where Text is of the form 0xFF0000 if(parsedhex)    //...   doesn't work. What am i doing wrong?
96218
I came across this code and wanted others to provide their point of view... is it good or bad ? ;)  Class ReportClass {  public string ReportName {get; set;} }   Then it was used as follows in code:  displayReport(ReportClass.ReportName = cmbReportName.SelectedValue.ToString())   That is about the simplest form example I can give you. Quetion is... why can't I find examples ? What would this be called? Is this just asking for trouble?  EDIT: I'm referring to the inplace assignment. Which I wasn't aware of until today
49686
Sometimes when I am debugging code in Eclipse it happens that although I can see and inspect class member variables without any difficulty I am unable to inspect the values of variables declared locally within functions. As an aside, any parameters to the current function lose their 'real' names and instead one sees their values listed in the Variables window as arg0, arg1, arg2, etc but at least the values are visible.  This is occurring at present in relation to classes defined within the core JDK. I have verified that the installed and current JRE is a JDK.  Is anybody able to shed some light on this behaviour?
40845
I wrote the two methods below to automatically select N distinct colors. It works by defining a piecewise linear function on the RGB cube. The benefit of this is you can also get a progressive scale if that's what you want, but when N gets large the colors can start to look similar. I can also imagine evenly subdividing the RGB cube into a lattice and then drawing points. Does anyone know any other methods? I'm ruling out defining a list and then just cycling through it. I should also say I don't generally care if they clash or don't look nice, they just have to be visually distinct.  public static List&lt;Color&gt; pick(int num) {     List&lt;Color&gt; colors = new ArrayList&lt;Color&gt;();     if (num &lt; 2)         return colors;     float dx = 1.0f / (float) (num - 1);     for (int i = 0; i &lt; num; i++) {         colors.add(get(i * dx));     }     return colors; }  public static Color get(float x) {     float r = 0.0f;     float g = 0.0f;     float b = 1.0f;     if (x &gt;= 0.0f &amp;&amp; x &lt; 0.2f) {         x = x / 0.2f;         r = 0.0f;         g = x;         b = 1.0f;     } else if (x &gt;= 0.2f &amp;&amp; x &lt; 0.4f) {         x = (x - 0.2f) / 0.2f;         r = 0.0f;         g = 1.0f;         b = 1.0f - x;     } else if (x &gt;= 0.4f &amp;&amp; x &lt; 0.6f) {         x = (x - 0.4f) / 0.2f;         r = x;         g = 1.0f;         b = 0.0f;     } else if (x &gt;= 0.6f &amp;&amp; x &lt; 0.8f) {         x = (x - 0.6f) / 0.2f;         r = 1.0f;         g = 1.0f - x;         b = 0.0f;     } else if (x &gt;= 0.8f &amp;&amp; x &lt;= 1.0f) {         x = (x - 0.8f) / 0.2f;         r = 1.0f;         g = 0.0f;         b = x;     }     return new Color(r, g, b); }
103112
When and why would somebody do the following:  doSomething( (MyClass) null );   Have you ever done this? Could you please share your experience?
113807
Why does the following code not work?  I want to instantiate prefabs in a list and then use  it as a GameObject like that :  public GameObject prefab;  void Start() {   ArrayList players = new ArrayList();    for(int i=0; i&lt;5; i++)   {         players.Add( (GameObject)Instantiate(prefab));   }    players[2].transform.position = new Vector3(1, 1, 1);  }   there is an error message
88016
I've spent more time than I should trying to get my ray picking program working. I'm pretty convinced my math is solid with respect to line plane intersection, but I believe the problem lies with the changing of the mouse screen touch into 3D world space.  Heres my code:      public void passTouchEvents(MotionEvent e){           int[] viewport = {0,0,viewportWidth,viewportHeight};         float x = e.getX(), y = viewportHeight - e.getY();          float[] pos1 = new float[4];         float[] pos2 = new float[4];         GLU.gluUnProject(   x, y, 0.0f,                             mViewMatrix, 0,                             mProjectionMatrix, 0,                             viewport, 0,                             pos1, 0);           GLU.gluUnProject(   x, y, 1.0f,                             mViewMatrix, 0,                             mProjectionMatrix, 0,                             viewport, 0,                             pos2, 0);     }   Just as a reference I've tried transforming the coordinates 0,0,0 and got an offset.  It would be appreciated if you would answer using OpenGL ES 2.0 code.
13449
I can't understand where the final keyword is really handy when it is used on method parameters.    If we exclude the usage of anonymous classes, readability and intent declaration then it seems almost worthless to me.   Enforcing that some data remains constant is not as strong as it seems.    If the parameter is a primitive then it will have no effect since the parameter is passed to the method as a value and changing it will have no effect outside the scope.  If we are passing a parameter by reference, then the reference itself is a local variable and if the reference is changed from within the method, that would not have any effect from outside of the method scope.    Consider the simple test example below. This test passes although the method changed the value of the reference given to it, it has no effect.  public void testNullify() {     Collection&lt;Integer&gt; c  = new ArrayList&lt;Integer&gt;();           nullify(c);     assertNotNull(c);            final Collection&lt;Integer&gt; c1 = c;     assertTrue(c1.equals(c));     change(c);     assertTrue(c1.equals(c)); }  private void change(Collection&lt;Integer&gt; c) {     c = new ArrayList&lt;Integer&gt;(); }  public void nullify(Collection&lt;?&gt; t) {     t = null; }
95490
Why am I getting an out of memory exception?  So this dies in C# on the first time through:  splitBitmaps.Add(neededImage.Clone(rectDimensions, neededImage.PixelFormat));   Where splitBitmaps is a List&lt;BitMap&gt; BUT this works in VB for at least 4 iterations:  arlSplitBitmaps.Add(Image.Clone(rectDimensions, Image.PixelFormat))  Where arlSplitBitmaps is a simple array list.  (And yes I've tried arraylist in c#)  This is the fullsection:  for (Int32 splitIndex = 0; splitIndex &lt;= numberOfResultingImages - 1; splitIndex++) {    Rectangle rectDimensions;    if (splitIndex &lt; numberOfResultingImages - 1)    {     rectDimensions = new Rectangle(splitImageWidth * splitIndex, 0,        splitImageWidth, splitImageHeight);    }    else    {     rectDimensions = new Rectangle(splitImageWidth * splitIndex, 0,       sourceImageWidth - (splitImageWidth * splitIndex), splitImageHeight);    }     splitBitmaps.Add(neededImage.Clone(rectDimensions, neededImage.PixelFormat));    }   neededImage is a Bitmap by the way.   I can't find any useful answers on the intarweb, especially not why it works just fine in VB.  Update:  I actually found a reason (sort of) for this working but forgot to post it.  It has to do with converting the image to a bitmap instead of just trying to clone the raw image if I remember.
44540
I have an image (PNG or JPG) inside which there is at least one pixel of a certain RGB color I know in advance.  I want to find the pixel(s) of that color  For example, I may have image.jpg, inside which I know some pixel has the RGB value 255,100,200. I want a program that will give me the list of pixels (if any) of that color in the image.  Anyone know of a tool to help me with that?  Thanks!
66105
When I use this RenderTarget:  renderTarget = new RenderTarget2D(GraphicsDevice, GraphicsDevice.Viewport.Width,     GraphicsDevice.Viewport.Height, false, SurfaceFormat.Color, DepthFormat.Depth24);   and draw something to it:  graphicsDevice.SetRenderTarget(renderTarget); // some drawing code here graphicsDevice.SetRenderTarget(null);   and then when I want to continue with drawing depth buffer seams to be clean. Why? Is possible to save it for future use?