Results 1 to 2 of 2
  1. #1
    marinavaries is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Exclamation help fixing bug in method to put secret message in image!

    Hi so i need to create a method with these requirements:

    putSecretMessageInImage - This method should put the length of the secret message (number of characters) inside the alpha channel of the very first pixel in the array. Note that messages may not be longer than 256 characters. Each character in the message should then be placed in each subsequent pixel's alpha channel. So, if you are to place the message "Help!", you would have to change the alpha data in the first 6 pixels. The first for the length and the next five for the characters. Note, you are changing the data inside the array.

    and this is what i have :

    public static void putSecretMessageInImage(int[] pixels,String message)
    {
    // ADD YOUR CODE HERE
    int alpha = pixels[0];
    alpha = alpha & 0xFFFFFF00;
    int length = message.length();
    alpha = alpha | length;
    pixels[0] = alpha;

    for (int i=1;i<length;i++)
    {
    int index = (int) pixels[i];
    char char1 = message.charAt(i);
    index = char1 & 0xFFFFFF00;
    pixels[i]= index;
    }

    }

    It doesnt quite do the job however i think im really close..if someone could please help me figure out my mistake that would be greatly appreciated!

  2. #2
    marinavaries is offline Member
    Join Date
    Nov 2010
    Posts
    6
    Rep Power
    0

    Default

    i fixed the last line to :
    pixels[i] = char1;

    this makes it better but it gives a weird character at the end of the encoded text that was not part of the message inserted

Similar Threads

  1. Help with fixing timer
    By acash229 in forum New To Java
    Replies: 1
    Last Post: 09-13-2010, 07:27 AM
  2. Secret of String references comparision.
    By Anjaneyulu in forum Advanced Java
    Replies: 15
    Last Post: 02-24-2010, 03:32 PM
  3. [SOLVED] I need help fixing an error
    By leonardjr in forum New To Java
    Replies: 8
    Last Post: 02-21-2009, 09:33 PM
  4. help with fixing my assignment.please...error
    By Jin-enigma-PL in forum New To Java
    Replies: 4
    Last Post: 02-05-2009, 01:12 AM
  5. Exception Error need help fixing
    By skinnybones in forum New To Java
    Replies: 2
    Last Post: 12-03-2007, 08:14 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •