Converting bytes to shorts using arrays and NIO buffers - is this a bug?

I'm benchmarking the various methods for converting a sequence of bytes into shorts. I tried copying a byte array, a direct NIO buffer and a non-direct NIO buffer to a short array (using little-endian byte order). My results were a little confusing to me. As I understand it, direct buffers are basically native buffers - allocated by the OS instead of on the runtime's managed heap, hence their higher allocation cost and ability to perform quicker IO with channels that can use them directly. I also got the impression that non-direct buffers (which have a backing array) are basically just regular Java arrays wrapped in a ByteBuffer.
I didn't expect a huge difference between the results of my three tests, though I thought the two NIO methods might perform a bit quicker if the virtual machine was smart enough to notice that little-endian is my system's native byte order (hence allowing the chunk of memory to simply be copied, rather than applying a bunch of shifts and ORs to the bytes). Conversion with the direct NIO buffer was indeed faster than my byte array method, however the non-direct NIO buffer performed over ten times slower than even my array method. I can see it maybe performing a millisecond or two slower than the array method, what with virtual function call overhead and a few if checks to see what byte order should be used and what not, but shouldn't that method basically be doing exactly the same thing as my array method? Why is it so horribly slow?
Snippet:
import java.nio.*;
public class Program {
  public static final int LOOPS = 500;
  public static final int BUFFER_SIZE = 1024 * 1024;
  public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16) {
    for(int i = 0; i < buffer16.length; i += 2){
      buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
  public static void main(String[] args) {
    short[] shorts = new short[BUFFER_SIZE >>> 1];
    byte[] arrayBuffer = new byte[BUFFER_SIZE];
    ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
    ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
    long start;
    start = System.currentTimeMillis();
    for(int i = 0; i < LOOPS; ++i) copyByteArrayToShortArrayLE(arrayBuffer, shorts);
    long timeArray = System.currentTimeMillis() - start;
    start = System.currentTimeMillis();
    for(int i = 0; i < LOOPS; ++i) directBuffer.asShortBuffer().get(shorts);
    long timeDirect = System.currentTimeMillis() - start;
    start = System.currentTimeMillis();
    for(int i = 0; i < LOOPS; ++i) nonDirectBuffer.asShortBuffer().get(shorts);
    long timeNonDirect = System.currentTimeMillis() - start;
    System.out.println("Array:      " + timeArray);
    System.out.println("Direct:     " + timeDirect);
    System.out.println("Non-direct: " + timeNonDirect);
}Result:
Array:      328
Direct:     234
Non-direct: 4860

Using JDK1.6.0_18 on Ubuntu 9.1 I typically get
Array: 396
Direct: 550
Non-direct: 789
I think your tests are a little too short for accurate timings because they are likely to be significantly influenced by the JIT compilation.
If I change to use a GIT warmup i.e.
public static final int LOOPS = 500;
    public static final int WARMUP_LOOPS = 500;
    public static final int BUFFER_SIZE = 1024 * 1024;
    public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
        for (int i = 0; i < buffer16.length; i += 2)
            buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
    public static void main(String[] args)
        short[] shorts = new short[BUFFER_SIZE >>> 1];
        byte[] arrayBuffer = new byte[BUFFER_SIZE];
        ByteBuffer directBuffer = ByteBuffer.allocateDirect(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        ByteBuffer nonDirectBuffer = ByteBuffer.allocate(BUFFER_SIZE).order(ByteOrder.LITTLE_ENDIAN);
        long start = 0;
        for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
            if (i == 0)
                start = System.currentTimeMillis();
            copyByteArrayToShortArrayLE(arrayBuffer, shorts);
        long timeArray = System.currentTimeMillis() - start;
        for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
            if (i == 0)
                start = System.currentTimeMillis();
            directBuffer.asShortBuffer().get(shorts);
        long timeDirect = System.currentTimeMillis() - start;
        for (int i = -WARMUP_LOOPS; i < LOOPS; ++i)
            if (i == 0)
                start = System.currentTimeMillis();
            nonDirectBuffer.asShortBuffer().get(shorts);
        long timeNonDirect = System.currentTimeMillis() - start;
        System.out.println("Array:      " + timeArray);
        System.out.println("Direct:     " + timeDirect);
        System.out.println("Non-direct: " + timeNonDirect);
    }then I typically get
Array: 365
Direct: 528
Non-direct: 750
and if I change to 50,000 loops I typically get
Array: 37511
Direct: 57199
Non-direct: 73913
You also seem to have a bug in your copyByteArrayToShortArrayLE() method. Should it not be
public static void copyByteArrayToShortArrayLE(byte[] buffer8, short[] buffer16)
        for (int i = 0; i < buffer8.length; i += 2)
            buffer16[i >>> 1] = (short) ((buffer8[i] & 0xff) | ((buffer8[i + 1] & 0xff) << 8));
    }Edited by: sabre150 on Jan 27, 2010 9:07 AM

Similar Messages

  • Converting byte[] to short, long, etc.

    I need to packetize the data with my own header embedded in the data. The header field is composed of data types: short, byte, and long. Since the header will be transported over the network using UDP socket, it will have to be converted to type byte[].
    Is there a clean way to convert from byte[] to short, and long data types? Or do I have to concatenate bytes and type cast them? How do I even type cast byte[] to short? Thanks.

    Have a look at the ByteBuffer class. You can wrap a byte
    array in such a buffer and write other types (like ints or longs etc)
    to the byte array through the buffer. Of course you can read those
    values back again using the buffer.
    kind regards,
    Jos

  • Converting from spreadshet string to array and then back to spreadsheet string

    My questions is; why is the Spreadsheet string to array function creating more data than the original string had when you change the array back into a spreadsheet string. Im trying to analyze a comma delimited file using array functions since my column and row size is constant, but my data varies. Thus my reason for not using string parsing functions which would get more involved and difficult. So, however, after i convert to a 2D array of data from the comma delimited file I read from, and then I convert back to string using the Array to Spreadsheet String, I get added columns to the file, which prevents another program from receiving these files. Also, the data which I am reading is not all contiguous, it has gaps in some places for empty data. Looking at the file compared to the original after it has gone from string to array and then back to string again, looks almost identical except for the file size which got larger by 400 bytes and where the original file has empty spaces, the new file has a lot of commas added. Any idea?
    Charles

    The result you get is normal when the spreadsheet string contains rows of uneven length. Since the array rows have the same number of elements, nil values are added during the coonversion. And of course, the back to string conversion keep those added values in the string, with the associated commas.
    example : 3 x 3 array
    1,2,3
    4
    5,6,7
    is converted into
    1 2 3
    4 0 0
    5 6 7
    then back to
    1,2,3
    4,0,0
    5,6,7
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Is there an easier way to convert bytes into bit(boolean) arrays?

    I am currently using this method to convert bytes into bit arrays:
    /*convert byte to int such that it is between 0-255 this is the bytes[] array
                        if ((bytes/128)==1)
                             bit[c+0]=true;
                        else
                             bit[c+0]=false;
                        if ((bytes[i]-bitInt[c+0]*128)/64==1)
                             bit[c+1]=true;
                        else
                             bit[c+1]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64)/32==1)
                             bit[c+2]=true;
                        else
                             bit[c+2]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64-bitInt[c+2]*32)/16==1)
                             bit[c+3]=true;
                        else
                             bit[c+3]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64-bitInt[c+2]*32-bitInt[c+3]*16)/8==1)
                             bit[c+4]=true;
                        else
                             bit[c+4]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64-bitInt[c+2]*32-bitInt[c+3]*16-bitInt[c+4]*8)/4==1)
                             bit[c+5]=true;
                        else
                             bit[c+5]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64-bitInt[c+2]*32-bitInt[c+3]*16-bitInt[c+4]*8-bitInt[c+5]*4)/2==1)
                             bit[c+6]=true;
                        else
                             bit[c+6]= false;
                        if ((bytes[i]-bitInt[c+0]*128-bitInt[c+1]*64-bitInt[c+2]*32-bitInt[c+3]*16-bitInt[c+4]*8-bitInt[c+5]*4-bitInt[c+6]*2)==1)
                             bit[c+7]=true;
                        else
                             bit[c+7]= false;

    You can loop through and use a bitwise operator instead. Here is an example without the loop.
    byte b = 6 ;
    if( b & Math.pow( 2, 0 ) == Math.pow( 2, 0 ) ) ;
    // the 2^0 bit is on
    if( b & Math.pow( 2, 1 ) == Math.pow( 2, 1 ) ) ;
    // the 2^1 bit is onetc...
    You should get something like 110 when you're done.
    If you're wonder what & does (no, its not a boolean &&), it takes the bits in the two numbers you give it and returns a number with all the bits on that are on for each of them.
    For example:
    10011011 &
    11001101 =
    10001001
    So if we take
    110 (6) &
    010 (2^1, or 2) =
    010 (2 again)
    Which means that the number (6) has the 2^1 bit on.

  • Possible to use arrays and merge?

    Is it possible to use the results of APEX_UTIL.STRING_TO_TABLE in a merge statement? For example:
    l_selected := APEX_UTIL.STRING_TO_TABLE(:P4_V_METHODS);<br>
    l_methods := APEX_UTIL.STRING_TO_TABLE(:P4_VERIFICATION_SEQ);<p>
    merge into verification_results vr<br>
         using l_methods on (<br>
         l_methods = vr.verification_seq<br>
    ) <br>
    WHEN MATCHED THEN ...<p>
    etc.<p>
    It's a bit of a convoluted task that may not be possible. I've got checkboxes that hold the reference values (method_seq) and a hidden item that returns a string of the primary keys of a rel table (verification_results.verification_seq) and I want to merge what was stored and any new/different things that were checked.
    Y'all are going to want an example on apex.oracle.com, aren't you...
    thanks!

    Short answer, no. Used a couple arrays and loops instead.

  • Another trick of using array and getpixel

    Hi,
    this is my reference to get Median 5 x 5px (Horizontal and Vertical Diverence Value)
    this is my code,.
    public static int[] limitMed(Bitmap myBmp)
    //Input: Bitmap 68 x 68px (Grayscale)
    //Output: Array of Median 5 x 5px (Horizontal and Vertical Diverence Value) - Just like the picture
    //Ignore 2px to each sides (i just need 64 x 64px inside)
    int[] myValue = new int[(myBmp.Width - 4) * (myBmp.Height - 4)];//Array for Output Value
    int[] tempHValue = new int[20];//Array for Horizontal Diverence Value
    int[] tempVValue = new int[20];//Array for Vertical Diverence Value
    int countV = 0;// Count Value
    for (int j = 2; j < myBmp.Height - 2; j++)//Ignore 2px top and bottom side
    for (int i = 2; i < myBmp.Width - 2; i++)//Ignore 2px left and right side
    int countHT = 0;
    for (int y = j - 2; y <= j + 2; y++)
    for (int x = i - 2; x < i + 2; x++)
    Color myClr1 = myBmp.GetPixel(x, y);
    Color myClr2 = myBmp.GetPixel(x + 1, y);
    tempHValue[countHT] = Math.Abs(myClr1.R - myClr2.R);//Get horizontal diverence value
    countHT++;
    List<int> listH = new List<int>(tempHValue);//Add horizontal diverence value to List
    int countVT = 0;
    for (int y = i - 2; y <= i + 2; y++)
    for (int x = j - 2; x < j + 2; x++)
    Color myClr1 = myBmp.GetPixel(y, x);
    Color myClr2 = myBmp.GetPixel(y, x + 1);
    tempVValue[countVT] = Math.Abs(myClr1.R - myClr2.R);//Get vertical diverence value
    countVT++;
    List<int> listV = new List<int>(tempVValue);//Add vertical diverence value to List
    var result = listH.Concat(listV);//Combine Lists
    List<int> resultList = result.ToList();
    resultList.Sort();//Sort List
    List<int> rangeList = resultList.GetRange(19, 2);//Get 19th and 20th value
    myValue[countV] = (int)rangeList.Average();//Add Median to Array
    countV++;
    return myValue;// return Array
    this code is running but not too fast,
    there is any idea to repair this code?
    Thanks!

    //////////////////////// // TODO: Your per-pixel code here. // The pixel contains 8-bit non-linear (sRGB) data. // See wikipedia: http://en.wikipedia.org/wiki/SRGB // for conversions betwen sRGB and Linear RGB. // Do your arithmetic on linear RGB values
    only.
    // pixel[0]: (sRGB) RED value
    // pixel[1]: (sRGB) GREEN value
    // pixel[2]: (sRGB) BLUE value
    //////////////////////// pixel += bytesPerPixel;
    } } ); } myBitmap.UnlockBits( bmdata );
    Hi,
    afaik the order is reversed BGR format so p[0] is blue - at least for 32bppArgb locked bmps.
    Here's my Median Filter for Bitmaps using unsafe code (This does something else than the OPs code, it doesnt "middle" the differences but the color channel values - as a Filter for images, can be optimized)
    private void button1_Click(object sender, EventArgs e)
    MedianFilter((Bitmap)this.pictureBox1.Image, 9 /* 9x9 Kernel */, true /* if pic doesnt contain transparecy, set this to false */, 255, null);
    this.pictureBox1.Refresh();
    //Median Filter, processing all pixels (edge/near-edge values too)
    //Conveniant, fast, but not fastest implementation (due to the variable size of the kernel to imput into the method).
    //params:
    //InputBitmap,
    //KernelSize,
    //take median for alpha channel,
    //maxSize of KernelRow/Column,
    //a reference to a BackgroundWorker to cancel/stop the opertation
    public static bool MedianFilter(Bitmap bmp, int size, bool doTrans, int maxSize, System.ComponentModel.BackgroundWorker bgw)
    if ((size & 0x1) != 1)
    throw new Exception("Kernelrows Length must be Odd.");
    if (size < 3)
    throw new Exception("Kernelrows Length must be in the range from 3 to" + (Math.Min(bmp.Width - 1, bmp.Height - 1)).ToString() + ".");
    if (size > maxSize)
    throw new Exception("Kernelrows Length must be in the range from 3 to" + maxSize.ToString() + ".");
    if (size > Math.Min(bmp.Width - 1, bmp.Height - 1))
    throw new Exception("Kernelrows Length must be in the range from 3 to" + (Math.Min(bmp.Width - 1, bmp.Height - 1)).ToString() + ".");
    int h = size / 2;
    Bitmap bSrc = null;
    BitmapData bmData = null;
    BitmapData bmSrc = null;
    try
    bSrc = (Bitmap)bmp.Clone();
    bmData = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height),
    ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
    bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height),
    ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
    int stride = bmData.Stride;
    System.IntPtr Scan0 = bmData.Scan0;
    System.IntPtr SrcScan0 = bmSrc.Scan0;
    unsafe
    int nWidth = bmp.Width;
    int nHeight = bmp.Height;
    int llh = h * stride;
    int lh = h * 4;
    # region First Part
    for (int l = 0; l < h; l++)
    byte* p = (byte*)(void*)Scan0;
    byte* pSrc = (byte*)(void*)SrcScan0;
    int lf = l * stride;
    int ll = l * 4;
    byte[] red = new byte[(h + 1) * (h + l + 1)];
    byte[] green = new byte[(h + 1) * (h + l + 1)];
    byte[] blue = new byte[(h + 1) * (h + l + 1)];
    byte[] alpha = new byte[(h + 1) * (h + l + 1)];
    int mid = red.Length / 2;
    for (int r = h - l, rc = 0; r < size; r++, rc++)
    int lr = rc * stride;
    for (int c = h, cc = 0; c < size; c++, cc++)
    int lcc = cc * 4;
    blue[rc * h + cc] = pSrc[lr + lcc];
    green[rc * h + cc] = pSrc[1 + lr + lcc];
    red[rc * h + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * h + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += lf;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    for (int x = 1, ccc = 1; x < nWidth - 1; x++, ccc++)
    p = (byte*)(void*)Scan0;
    pSrc = (byte*)(void*)SrcScan0;
    if (x > size - (h + 1))
    p += (x - size + (h + 1)) * 4;
    pSrc += (x - size + (h + 1)) * 4;
    ccc = (bmp.Width - x >= h + 1) ? Math.Min(ccc, h) : bmp.Width - x - 1;
    int fc = (h + ccc + 1);
    red = new byte[fc * (h + l + 1)];
    green = new byte[fc * (h + l + 1)];
    blue = new byte[fc * (h + l + 1)];
    alpha = new byte[fc * (h + l + 1)];
    mid = red.Length / 2;
    for (int r = h - l, rc = 0; r < size; r++, rc++)
    int lr = rc * stride;
    for (int c = Math.Max(h - x, 0), cc = 0; (x - h + size <= bmp.Width) ? c < size : c < (size - (x - h + size - bmp.Width)); c++, cc++)
    int lcc = cc * 4;
    blue[rc * fc + cc] = pSrc[lr + lcc];
    green[rc * fc + cc] = pSrc[1 + lr + lcc];
    red[rc * fc + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * fc + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p = (byte*)(void*)Scan0;
    p += lf + (x * 4);
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    p = (byte*)(void*)Scan0;
    p += (nWidth - h - 1) * 4;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += (nWidth - h - 1) * 4;
    red = new byte[(h + 1) * (h + l + 1)];
    green = new byte[(h + 1) * (h + l + 1)];
    blue = new byte[(h + 1) * (h + l + 1)];
    alpha = new byte[(h + 1) * (h + l + 1)];
    mid = red.Length / 2;
    for (int r = h - l, rc = 0; r < size; r++, rc++)
    int lr = rc * stride;
    for (int c = 0, cc = 0; c < size - h; c++, cc++)
    int lcc = cc * 4;
    blue[rc * h + cc] = pSrc[lr + lcc];
    green[rc * h + cc] = pSrc[1 + lr + lcc];
    red[rc * h + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * h + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += lf + lh;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    # endregion
    # region Main Body
    //for (int y = 0; y < nHeight - size + 1; y++)
    Parallel.For(0, nHeight - size + 1, (y, loopState) =>
    byte* p = (byte*)(void*)Scan0;
    byte* pSrc = (byte*)(void*)SrcScan0;
    if (bgw != null && bgw.CancellationPending)
    loopState.Break();
    # region First Pixels
    byte[] red = new byte[(h + 1) * size];
    byte[] green = new byte[(h + 1) * size];
    byte[] blue = new byte[(h + 1) * size];
    byte[] alpha = new byte[(h + 1) * size];
    int mid = red.Length / 2;
    for (int l = 0; l < h; l++)
    p = (byte*)(void*)Scan0;
    p += y * stride;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += y * stride;
    int ll = l * 4;
    for (int r = 0, rc = 0; r < size; r++, rc++)
    int lr = rc * stride;
    for (int c = 0, cc = 0; c < (h + 1); c++, cc++)
    int lcc = cc * 4;
    blue[r * (h + 1) + cc] = pSrc[lr + lcc];
    green[r * (h + 1) + cc] = pSrc[1 + lr + lcc];
    red[r * (h + 1) + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[r * (h + 1) + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += llh + ll;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    # endregion
    # region Standard
    red = new byte[size * size];
    green = new byte[size * size];
    blue = new byte[size * size];
    alpha = new byte[size * size];
    mid = red.Length / 2;
    for (int x = 0; x < nWidth - size + 1; x++)
    p = (byte*)(void*)Scan0;
    p += y * stride + x * 4;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += y * stride + x * 4;
    for (int r = 0; r < size; r++)
    int llr = r * stride;
    for (int c = 0; c < size; c++)
    int lc = c * 4;
    blue[r * size + c] = pSrc[llr + lc];
    green[r * size + c] = pSrc[1 + llr + lc];
    red[r * size + c] = pSrc[2 + llr + lc];
    if (doTrans)
    alpha[r * size + c] = pSrc[3 + llr + lc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += llh + lh;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    # endregion
    # region Last Pixels
    red = new byte[(h + 1) * size];
    green = new byte[(h + 1) * size];
    blue = new byte[(h + 1) * size];
    alpha = new byte[(h + 1) * size];
    mid = red.Length / 2;
    for (int l = nWidth - size + 1; l < nWidth - h; l++)
    int ll = l * 4;
    p = (byte*)(void*)Scan0;
    p += (y * stride) + ll;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += (y * stride) + ll;
    for (int r = 0, rc = 0; r < size; r++, rc++)
    int lr = rc * stride;
    for (int c = 0, cc = 0; c < h + 1; c++, cc++)
    int lcc = cc * 4;
    blue[r * (h + 1) + cc] = pSrc[lr + lcc];
    green[r * (h + 1) + cc] = pSrc[1 + lr + lcc];
    red[r * (h + 1) + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[r * (h + 1) + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += llh + lh;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    # endregion
    # endregion
    # region Last Part
    for (int l = 0; l < h; l++)
    byte* p = (byte*)(void*)Scan0;
    byte* pSrc = (byte*)(void*)SrcScan0;
    p += (nHeight - size + l + 1) * stride;
    pSrc += (nHeight - size + l + 1) * stride;
    int lf = l * stride;
    int ll = l * 4;
    byte[] red = new byte[(h + 1) * (size - l - 1)];
    byte[] green = new byte[(h + 1) * (size - l - 1)];
    byte[] blue = new byte[(h + 1) * (size - l - 1)];
    byte[] alpha = new byte[(h + 1) * (size - l - 1)];
    int mid = red.Length / 2;
    for (int r = 0, rc = 0; r < size - (l + 1); r++, rc++)
    int lr = rc * stride;
    for (int c = h, cc = 0; c < size; c++, cc++)
    int lcc = cc * 4;
    blue[rc * h + cc] = pSrc[lr + lcc];
    green[rc * h + cc] = pSrc[1 + lr + lcc];
    red[rc * h + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * h + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += llh;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    for (int x = 1, ccc = 1; x < nWidth - 1; x++, ccc++)
    p = (byte*)(void*)Scan0;
    p += (nHeight - size + l + 1) * stride;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += (nHeight - size + l + 1) * stride;
    if (x > size - (h + 1))
    p += (x - size + (h + 1)) * 4;
    pSrc += (x - size + (h + 1)) * 4;
    ccc = (bmp.Width - x >= h + 1) ? Math.Min(ccc, h) : bmp.Width - x - 1;
    int fc = (h + ccc + 1);
    red = new byte[fc * (size - l - 1)];
    green = new byte[fc * (size - l - 1)];
    blue = new byte[fc * (size - l - 1)];
    alpha = new byte[fc * (size - l - 1)];
    mid = red.Length / 2;
    for (int r = 0, rc = 0; r < size - (l + 1); r++, rc++)
    int lr = rc * stride;
    for (int c = Math.Max(h - x, 0), cc = 0; (x - h + size <= bmp.Width) ? c < size : c < (size - (x - h + size - bmp.Width)); c++, cc++)
    int lcc = cc * 4;
    blue[rc * fc + cc] = pSrc[lr + lcc];
    green[rc * fc + cc] = pSrc[1 + lr + lcc];
    red[rc * fc + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * fc + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p = (byte*)(void*)Scan0;
    p += (nHeight - size + l + 1) * stride;
    p += llh + (x * 4);
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    p = (byte*)(void*)Scan0;
    p += (nHeight - size + l + 1) * stride;
    p += (nWidth - h - 1) * 4;
    pSrc = (byte*)(void*)SrcScan0;
    pSrc += (nHeight - size + l + 1) * stride;
    pSrc += (nWidth - h - 1) * 4;
    red = new byte[(h + 1) * (size - l - 1)];
    green = new byte[(h + 1) * (size - l - 1)];
    blue = new byte[(h + 1) * (size - l - 1)];
    alpha = new byte[(h + 1) * (size - l - 1)];
    mid = red.Length / 2;
    for (int r = 0, rc = 0; r < size - (l + 1); r++, rc++)
    int lr = rc * stride;
    for (int c = 0, cc = 0; c < size - h; c++, cc++)
    int lcc = cc * 4;
    blue[rc * h + cc] = pSrc[lr + lcc];
    green[rc * h + cc] = pSrc[1 + lr + lcc];
    red[rc * h + cc] = pSrc[2 + lr + lcc];
    if (doTrans)
    alpha[rc * h + cc] = pSrc[3 + lr + lcc];
    Array.Sort(red);
    Array.Sort(green);
    Array.Sort(blue);
    Array.Sort(alpha);
    p += llh + lh;
    p[0] = blue[mid];
    p[1] = green[mid];
    p[2] = red[mid];
    if (doTrans)
    p[3] = alpha[mid];
    # endregion
    bmp.UnlockBits(bmData);
    bSrc.UnlockBits(bmSrc);
    bSrc.Dispose();
    return true;
    catch
    try
    bmp.UnlockBits(bmData);
    catch
    try
    bSrc.UnlockBits(bmSrc);
    catch
    if (bSrc != null)
    bSrc.Dispose();
    bSrc = null;
    return false;
    Regards,
      Thorsten

  • RAID 5 array. 2 arrays (/) and (/home) - asks about this

    Hello pals. On wiki, we'have that it's necessary create the array with mdadm, after assemble, and after installs arch like anyother disk system, just add while in chroot "mdadm_udev" and run "mkinitcpio -p linux"
    My question, however, is:
    In a first try, I don't know if I did the mistake, but my /home partition were mounted, with, the root partition. So "not enough space".
    I've reinstalled all again, Everithing working since, but yesterday, arch halts and, after reboot, I "lost" my /home, and not "md0" and "md1" devices, but "md126" and "md127" ones are founded on my arrays, and, no more linux.
    fsck didn't work (not found the uuid XXXX partition"
    I'm using a RAID5 scheme with "md0" as /root and "md1" as /home. md0 with 3 hard disks and md1 with three too.
    RAID is a LSICorp with 21320R 6 bay. HD SCSI
    partition type were XFS to "root" and "ext4" to /home.
    Begginer's guide to install, and
    https://wiki.archlinux.org/index.php/RAID
    to create RAID

    Ok... everything reinstaled.
    sdc                                                                       
    └─sdc1  linux_raid_member archiso:0   5a556144-7cad-36e1-b969-300e33e42055
      └─md0 xfs               root        3cd56eab-5747-4468-92e0-d53baf0d5544 /
    sdd                                                                       
    └─sdd1  linux_raid_member archiso:0   5a556144-7cad-36e1-b969-300e33e42055
      └─md0 xfs               root        3cd56eab-5747-4468-92e0-d53baf0d5544 /
    sde                                                                       
    └─sde1  linux_raid_member archiso:0   5a556144-7cad-36e1-b969-300e33e42055
      └─md0 xfs               root        3cd56eab-5747-4468-92e0-d53baf0d5544 /
    sdf                                                                       
    └─sdf1  linux_raid_member archiso:1   d27f91fb-ed92-12a7-340c-11b8636d491f
      └─md1 ext4              home        6cb919d4-9016-4a7b-8336-01a1244a0630 /home
    sdg                                                                       
    └─sdg1  linux_raid_member archiso:1   d27f91fb-ed92-12a7-340c-11b8636d491f
      └─md1 ext4              home        6cb919d4-9016-4a7b-8336-01a1244a0630 /home
    sdh                                                                       
    └─sdh1  linux_raid_member archiso:1   d27f91fb-ed92-12a7-340c-11b8636d491f
      └─md1 ext4              home        6cb919d4-9016-4a7b-8336-01a1244a0630 /home
    cat /proc/mdstat
    cat /proc/mdstat
    Personalities : [raid6] [raid5] [raid4]
    md1 : active raid5 sdh1[3] sdg1[1] sdf1[0]
          142884864 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]
    md0 : active raid5 sde1[3] sdc1[0] sdd1[1]
          70778880 blocks super 1.2 level 5, 64k chunk, algorithm 2 [3/3] [UUU]
    /etc/fstab
    # /etc/fstab: static file system information
    # <file system> <dir>   <type>  <options>       <dump>  <pass>
    # /dev/md0 LABEL=root
    UUID=3cd56eab-5747-4468-92e0-d53baf0d5544       /               xfs             rw,relatime,attr2,inode64,logbsize=64k,sunit=128,swidth=256,noquota  0 1
    # /dev/md1 LABEL=home
    UUID=6cb919d4-9016-4a7b-8336-01a1244a0630       /home           ext4            rw,relatime,stripe=192,data=ordered  0 2
    Anything to change?
    I remember that the ~last problem~ were during a upgrade.

  • I cannot open iMovie - it says I need a "Graphics card that is compatible with Quartz Extreme" I know this is wrong- Have iMovie version 9.0.4, regularly use it and have not had this problem before

    Details: On my MacBook Pro, I have MacOS X 10.6.8, a 2.26 GHz IntelCore Duo processor with 4 GB 1067 MHz DOR 3 Memory.
    I have iMovie Version 9.0.4, which I apparently updated inJuly.  I regularly used iMovie, and last used it about 3 weeks ago.  However, Today, when I try to get into iMovie, I get thefollowing message:
    “Quartz extreme Required  iMovie requires agraphics card that is compatible with Quartz Extreme.  One or more of your graphics cards does ntosupport Quartz Extreme.”
    So, I cannot get into my iMovie.  I know the “Quartz Extreme” message ismistaken.  WHAT DO I DO?

    I would recommend that you turn off and restart your Mac. That should clear it up.

  • How do i use Arrays and For Loops in Loading Multiple Images?

    I am struggling to load a sequential array of images to appear like a moving image. So when u click the button the images load one after the other.
    The code below is what i have so far, but it fails to do what i seek in that there's only one image loading which is the last image in the array, so either because the images are stacking up atop each other, or because i simply dont understand the basics...
    And, i am unclear about what you said kglad, that my solution will be more complicated because i need to preload my image sequence and then use a loop to load it?
    import flash.net.URLRequest;
    import flash.display.Loader;
    var count:int = 0;
    var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7.jpg",
    "8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
    for(var i:uint=0;i<imageArray.length;i++){
    var btn:YourButton=new YourButton();
    btn.ivar=i;
    addChild(btn);
    btn.x=0;
    btn.y=0;
    btn.addEventListener(MouseEvent.CLICK,clickF);
    var ldr:Loader=new Loader();
    addChild(ldr);
    ldr.x=20;
    ldr.y=20;
    function clickF(e:MouseEvent){
        ldr.load(new URLRequest("D:/flash cs5.5/image_sequence/twirlSeq/"+imageArray[e.currentTarget.ivar]));
    function loadComplete(e:Event){
         // first process loaded image, then...
        count++;
        if(count < imageArray.length){
            loadCurrentImage();  // load the next image
        } else {
            // sequencial loading complete, carry on to next activity
    function loadCurrentImage(){
         ldr.load(imageArray[count]);
         ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

    create a new fla, add btn and add the code i suggested.  test.
    var count:int;
    var imageArray:Array=["1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg","7. jpg",
    "8.jpg","9.jpg","10.jpg","11.jpg","12.jpg","13.jpg"];
    var ldr0:Loader=new Loader();
    ldr0.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
    var ldr1:Loader=new Loader();
    ldr1.contentLoaderInfo.addEventListener(Event.COMPLETE,loadCompleteF);
    btn.addEventListener(MouseEvent.CLICK,clickF);
    function clickF(e:MouseEvent):void{
    // initialize count
    count=0;
    // call loadF
    loadF();
    function loadF():void{
    // add one of the loaders to the top of the displaylist and load the next image
    addChild(this["ldr"+count%2])
    this["ldr"+count%2].load(new URLRequest(imageArray[count]));
    function loadCompleteF(e:Event):void{
    // increment count
    count++;
    // check if the last has loaded
    if(count<imageArray.length){
    // if not clear the content out of the next loader.
    if(this["ldr"+count%2].content){
    this["ldr"+count%2].unloadAndStop();
    // and call loadF so the next loader can load the next image in the array
    loadF();
    } else {
    // if the last has loaded.
    // last load completed

  • Screen Pixalation when using Sleep and Auto Logout problems. OS bug?

    Original Thread here: http://forums.macrumors.com/showthread.php?t=1295058
    Thread Tools
    Search this Thread
    Display Modes
    Dec 21, 2011, 01:01 PM
      #1
    gswilder
    macrumors regular
    Join Date: Oct 2007
    iMac Sleep Problem Waking - Screen Black & Pixelization
    Have a new BTO 27" iMac I received a couple of weeks ago. Of course it is running Lion 10.7....
    I am having a screen problem "waking" my iMac. (I also have this problem randomly on my MB Air - mid 2011 model)
    After the iMac is in true sleep mode
    (I have it set to enter a password after sleep mode)
    Screen is blank/off
    I "wiggle" my mouse or trackpad
    Screen is still blank (sometimes it may display my screen saver, but the screensaver is frozen)
    If I start moving the mouse or trackpad, it starts "un painting" the black screen. You can see whatever is supposed to be on the screen, such as the logon "button".
    It is really wierd. Like a black "overlay" is painted on the resume from sleep screen. As I move my mouse or trackpad, it is basically erasing the black, to show what is underneath. Each movement of the mouse, erases a small black square.
    I usually move my mouse around the middle of the screen to uncover the logon button. Press the logon button. The screen magically reappears as normal. I enter my password and system logs back on normally.
    It only seems to be when the iMac is in really deep sleep mode. If the screen is just blank for an hour or so. I move the mouse/trackpad, and the logon screen is immediately displayed normally.
    Any thoughts or recommendations?
    Thanks to all in advance.
    Greg
    0  
    Dec 23, 2011, 12:17 AM
      #2
    gswilder
    Thread Starter
    macrumors regular
    Join Date: Oct 2007
    UPdate
    Still experimenting.
    If certain programs are running (ie Firefox), then I don't have a problem coming out of deep sleep. It gives me a message when I reenter my password, that Firefox prevented the system from logging off.
    Does that additional information help? It is a really annoying problem. And since I have it on my MBA, I am concerned it is more widespread. Does anyone else have this issue?
    0  
    Dec 24, 2011, 09:18 PM
      #3
    UNCHeelYeah
    macrumors newbie
    Join Date: Dec 2011
    Black Screen and "Erasure" with Mouse.
    I am having this same problem. I am using the Mac OS X Lion 10.7.2, not using a screen saver, and it happens sporadically upon trying to wake my iMac from sleep mode. The screen is black, and as you move the mouse over the screen, it "erases" the black, like the opposite of a blackboard, to reveal the login name and picture underneath. After that everything works fine. There is no pattern to this that I can discern (e.g. - happens every fifth time, only happens when a program isn't running etc.). It appears random, but is uber annoying, and behaves like a virus. I have Norton Antivirus, and it updates daily, and upon scanning states no virus is found. I also do system scan with MacKeeper, and it scans, says system is excellent. Something is definitely going on, I just wish I knew what it was. If anyone has any knowledge of this, any solution or insight would be greatly appreciated! Thanks!
    0  
    Dec 25, 2011, 12:29 PM
      #4
    GGJstudios
    macrumors G4
    Join Date: May 2008
    Quote:
    Originally Posted by UNCHeelYeah
    It appears random, but is uber annoying, and behaves like a virus. I have Norton Antivirus, and it updates daily, and upon scanning states no virus is found.
    That's because there are no Mac OS X viruses. You should uninstall Norton. You don't need 3rd party antivirus apps to protect your Mac from malware. Macs are not immune to malware, but no true viruses exist in the wild that can run on Mac OS X, and there never have been any since it was released 10 years ago. The only malware in the wild that can affect Mac OS X is a handful of trojans, which can be easily avoided with some basic education, common sense and care in what software you install. Also, Mac OS X Snow Leopard and Lion have anti-malware protection built in, further reducing the need for 3rd party antivirus apps.
    Mac Virus/Malware Info
    Quote:
    Originally Posted by UNCHeelYeah
    I also do system scan with MacKeeper, and it scans, says system is excellent.
    You don't need MacKeeper, either. You really don't need "cleaner" or "maintenance" apps to keep your Mac running well, and some of these apps can do more harm than good. Most only remove files/folders or unused languages or architectures, which does nothing more than free up some drive space. It will not make your Mac run faster or more efficiently, since having stuff stored on a drive does not impact performance, unless you're running out of drive space.
    Mac OS X does a good job of taking care of itself, without the need for 3rd party software.
    Your problem, and the OP's is a graphics problem, likely having to do with the screensaver, not a malware problem.
    1  
    Dec 26, 2011, 08:13 AM
      #5
    UNCHeelYeah
    macrumors newbie
    Join Date: Dec 2011
    Norton Antivirus, and what does it mean?
    I suppose one reason I developed a concern that there was more here than meets the proverbial eye, so to speak was a message that I have received through Norton on multiple occasions. The last message of similar stated messages reads as follows (Norton Antivirus 2.2.1 (5) ): "Vulnerability blocked, December 13th, 2011, 8:57 P.M. When I click on "View Recent Activities", a window is opened that is titled "Activity Log." There, four columns are listed, titled from left to right "Date", "Event Type", "Result", and "Details." Under the December 13th episode, It lists "Portscan" under Event type, "Result" gives an IP Address (192.168.x.xxx), and "Incoming" under details.
    I am admittedly a neophyte in the Mac world, having switched over from Windows 7 to Mac recently, but am intent on educating myself to the not-so-subtle differences. The above information that Norton displayed would lead one to believe that their antivirus software is protecting my iMac, and that its subsequent removal would have perhaps disastrous results ( i.e. - my iMac would be susceptible to said "Vulnerability", whatever it is, and that "Incoming would NOT be blocked). I had a conversation with Norton because previously, every time the stated "Vulnerability" attempted access, I was interrupted by a pop-up screen informing me of this. The Norton representative was able to turn off the pop-up screen notification, but stated that it would continue to log episodes of the "Vulnerability" when it attempted to portscan and access. So am I to understand that uninstalling Norton would leave my computer no less vulnerable to this vulnerability? It is confusing to me.
    Furthermore, I suppose I did wonder if this vulnerability threat had anything to do with the issue of the black screen erasure with the mouse. I will attempt to post a picture of the screen as it was being erased with the mouse, and perhaps a short movie as well. As previously stated, I do not have a screen saver enabled. Thank you for your input, any information is helpful to me! _
    ~Marc
    http://forums.macrumors.com/attachment.php?attachmentid=317412&d=1324905189
    0  
    Dec 26, 2011, 11:19 AM
      #6
    gswilder
    Thread Starter
    macrumors regular
    Join Date: Oct 2007
    Ditto & FYI Workaround
    UncHeel...
    Thanks for posting the picture. It is same as my iMac problem. On my iMac, it happens 100% of the time. On my MBA, it happens randomly like yours.
    I began to notice if certain programs were running, when it went into screen saver and sleep mode, this didn't happen. And when I woke it up, I got a message that said "could not be logged off due to Firefox or Sketchbook Pro, etc. So that got me to thinking. So....
    Over the weekend, I disabled "logoff after xx minutes of activity" in system preferences. That seems to fix the issue. I still have it set to require a password after the screen saver/sleep mode kicks it. But I disabled the logoff toggle.
    Still not sure what this is an issue, but seems to be a work around. I just want to make sure my iMac is still going into sleep with these new settings. Including the monitor sleep.
    Any thoughts based on this new information?
    Thanks again
    Greg
    0  
    Dec 26, 2011, 11:52 AM
      #7
    GGJstudios
    macrumors G4
    Join Date: May 2008
    Quote:
    Originally Posted by UNCHeelYeah
    The above information that Norton displayed would lead one to believe that their antivirus software is protecting my iMac, and that its subsequent removal would have perhaps disastrous results
    You have to remember that many antivirus apps consider cookies to be a "vulnerability" or "threat", when they're not. The only malware in the wild that can affect Mac OS X requires the user to actively install it. As long as a user is reasonably careful about where they get software, there is no need for 3rd party antivirus apps to protect Mac OS X from malware. Just make sure your firewall is enabled (System Preferences > Security > Firewall), and disable Java in your browser (Safari > Preferences > Security > Enable Java (uncheck))
    Quote:
    Originally Posted by gswilder
    I just want to make sure my iMac is still going into sleep with these new settings. Including the monitor sleep.
    You can let it sleep without logging off. That way, your apps/documents are still open when you wake it up, rather than having to relaunch apps and reopen documents. Recovery from sleep is much faster than from logging off.
    0  
    Dec 27, 2011, 03:02 PM
      #8
    rda2w
    macrumors newbie
    Join Date: Oct 2011
    Quote:
    Originally Posted by gswilder
    UncHeel...
    Thanks for posting the picture. It is same as my iMac problem. On my iMac, it happens 100% of the time. On my MBA, it happens randomly like yours.
    I began to notice if certain programs were running, when it went into screen saver and sleep mode, this didn't happen. And when I woke it up, I got a message that said "could not be logged off due to Firefox or Sketchbook Pro, etc. So that got me to thinking. So....
    Over the weekend, I disabled "logoff after xx minutes of activity" in system preferences. That seems to fix the issue. I still have it set to require a password after the screen saver/sleep mode kicks it. But I disabled the logoff toggle.
    Still not sure what this is an issue, but seems to be a work around. I just want to make sure my iMac is still going into sleep with these new settings. Including the monitor sleep.
    Any thoughts based on this new information?
    Thanks again
    Greg
    I have had the same problem on my mid-2010 iMac since upgrading to Lion and it's been driving me nuts. The relation to automatic Logoff makes sense to me now that I look at my settings. The logoff was occurring after sleep and it's the only thing I haven't tried yet. I had previously thought it was related to Sleep but it never occurs if I force it to sleep. It only occurs after the system was left unattended and went through it's normal steps of screensaver then sleep. I'll try disabling the automatic Logoff and see if it fixes the problem for me too.
    -BA
    0  
    Dec 29, 2011, 10:58 AM
      #9
    rda2w
    macrumors newbie
    Join Date: Oct 2011
    Quote:
    Originally Posted by rda2w
    I have had the same problem on my mid-2010 iMac since upgrading to Lion and it's been driving me nuts. The relation to automatic Logoff makes sense to me now that I look at my settings. The logoff was occurring after sleep and it's the only thing I haven't tried yet. I had previously thought it was related to Sleep but it never occurs if I force it to sleep. It only occurs after the system was left unattended and went through it's normal steps of screensaver then sleep. I'll try disabling the automatic Logoff and see if it fixes the problem for me too.
    -BA
    I can only declare partial success with unpicking "logoff after xx". It solved the pixelated screen issue but now the computer is not sleeping. I guess I'll have to uncheck file sharing now.
    -BA
    0  
    Feb 6, 2012, 06:26 PM
      #10
    ougrad1764
    macrumors newbie
    Join Date: Apr 2010
    Any updates?
    Just wanted to see if there had been any changes since the last posting in this thread. I'm experiencing the same issue as OP on my 2011 13" MacBook Air w/ OS X 10.7.3, as well as on my parents' mid-2010 iMac (running OS X 10.7.2).
    I can't seem to pin down the cause and have tried the steps suggested previously. Thanks!
    0  
    Feb 21, 2012, 10:03 PM
      #11
    wchp
    macrumors newbie
    Join Date: Feb 2012
    Still having the same issue here as well.
    Have any of you tried a clean install of OSX?
    Before I try a full reinstall I did an install on a external drive with no aps, just the bare install and I could not replicate the issue.
    I continue to question if this is a graphics card firmware issue or and OS issue.
    A reinstall (overlay) of the OS did not resolve the issue.
    I have screen shots as follows:
    1) Paint pixels on screen
    http://i129.photobucket.com/albums/p227/wchp/iMac27%20Graphics%20Problem/photo1. jpg
    2) Click Icon
    http://i129.photobucket.com/albums/p227/wchp/iMac27%20Graphics%20Problem/photo2. jpg
    3) Type in PWD
    http://i129.photobucket.com/albums/p227/wchp/iMac27%20Graphics%20Problem/photo3. jpg
    4) Logged in:
    http://i129.photobucket.com/albums/p227/wchp/iMac27%20Graphics%20Problem/photo4. jpg
    Last edited by grapes911; Feb 21, 2012 at 10:12 PM. Reason: replaced img with timg
    0  
    Yesterday, 12:21 AM
      #12
    jrobin
    macrumors newbie
    Join Date: Feb 2012
    Having the same issue
    I have four MacBooks and a MacBook Air. I am seeing this issue on two MacBooks both running Lion 10.7.3. One is a newer i5 MacBook the other is an early 2010. The only common denominator I can think of is they are both set up with Parental Controls and they are set to logoff after X amount of time. The other MacBooks don't have this "pixel painting to revel the login screen issue" I also don't see it on our iMacs or the MacMini. Only the two with the issue are set to auto logoff. So the above poster is most likely on to something. I will give it a try by turning off the auto logoff on the two MacBooks in question. If that solves the problem then I will assume its a bug that needs to be addressed.
    0  
    Yesterday, 12:30 AM
      #13
    ougrad1764
    macrumors newbie
    Join Date: Apr 2010
    reinstall (overlay) of the OS did not resolve the issue
    wchp - Thank you for following up and posting the screenshots. They match exactly what I was experiencing (and what UNCHeelYeah reported previously). I can confirm that I experienced the issue even following a clean reinstall of Snow Leopard on my MacBook Air (13-inch, Mid 2011).
    jrobin - "I will give it a try by turning off the auto logoff on the two MacBooks in question. If that solves the problem then I will assume its a bug that needs to be addressed."
    Good thinking! Thanks for taking the time to test with your machines. This will help provide further validation of what gswilder (OP) tried as well in reply #6. Interesting about Parental Controls, too.
    Side note:
    Since I recently joined the Apple Developers program, I did a clean install of SL on my MBA then upgraded via the App Store to Mountain Lion to "kick-the-tires" if you will. Interestingly, I've not yet experienced any issue related to waking from sleep with a black screen and pixilation, even while running all the same apps I had previously. I'll report here (and file a bug report with Apple) if I do see this issue pop-up in ML. I'll be reinstalling SL in a few weeks and will report back if/when the black screen and pixelation issue reappears. I'll be sure to note the applications left running at the time the computer went to sleep.
    Last edited by ougrad1764; Yesterday at 12:44 AM. Reason: Follow-up to jrobin (reply came in while I was typing mine)
    0  
    Yesterday, 09:04 AM
      #14
    evillanueva
    macrumors newbie
    Join Date: Feb 2012
    I have experienced the same issue with my brand new MBA Late 2011.
    I recently found out that this only happens when DISPLAY is set to go to sleep minutes before the "Log out after X minutes of inactivity". I had "Display sleep" option set to 5 minutes and "Log out after 10 minutes of inactivity" and this causes the display to go to sleep first (screen goes black) and then, 5 minutes later, it logs out.
    If "Display sleep" is off and "Log out after X minutes of inactivity" is on, the issue does not replicate. So Im thinking it has something to do with the screen being black at the moment it logs out. Can you try and replicate that?
    Thanks
    0  
    Yesterday, 01:39 PM
      #15
    wchp
    macrumors newbie
    Join Date: Feb 2012
    Quote:
    Originally Posted by evillanueva
    I have experienced the same issue with my brand new MBA Late 2011.
    I recently found out that this only happens when DISPLAY is set to go to sleep minutes before the "Log out after X minutes of inactivity". I had "Display sleep" option set to 5 minutes and "Log out after 10 minutes of inactivity" and this causes the display to go to sleep first (screen goes black) and then, 5 minutes later, it logs out.
    If "Display sleep" is off and "Log out after X minutes of inactivity" is on, the issue does not replicate. So Im thinking it has something to do with the screen being black at the moment it logs out. Can you try and replicate that?
    Thanks
    Just tested this premise and yes, you are correct.
    IF: Screen saver ON after 5m AND require password immediately AND Sleep (Display) after 30m AND Logout after 60m I am able to reproduce the problem.
    IF: Screen Saver ON after 5m AND require password immediately AND Sleep (Display) after 30m AND Logut after xx NOT enabled, problem goes away
    IF: Screen Saver ON after 5m AND require password immediately AND Sleep (Display) OFF AND Logut after 60M enabled, problem goes away
    So on my machine (iMac 27, 3.4/i7, 16GB/1333, Radeon 6970m/2048MB, OSX 10.7.3
    It would appear that if I am running Monitor Sleep and it kicks in prior to LogOff then I am able to reproduce this artifact. Only Display sleep with immediate login OR Loguot should be used but not both.
    The only other thing to test is is I leave display sleep on, and screen saver on but with NO immediate password and enable logoff if the problem goes away.
    Testing for another day.
    I have linked this entire thread to a Apple support ticket and will report back on Apples response

    Thank you so much wchp, this is brilliant. I have had this annoying problem for a long time. I eventually rang Mac support, they did not know how to fix the problem as you have suggested so they instigated many hardware replacements which eventually left my iMac severely crippled. They eventually replaced it with the latest model. But I spent two months working with a disabled computer which really interfere with my work.
    Your solution appears to have solved my problem, at least so far, but I am hopeful that it is a permanent fix. I hope that your suggestions are taken up by Apple support. This may solve many users problems and avoid Apple making expensive fixes that don't actually work.
    I thought that the new iMac would not have the 'Wake up from sleep by painting in the login window' problem but it did, this really annoyed me. Anyway now the problem appears to be solved, it's not I will repost and keep working on it. Thanks again.

  • How to use regular expression using pattern and match concept for this scenario?

    Hi Guys,
    I have a string "We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle"
    I need to replace the numbers based on the below condition.
    if more then 5, replace with many
    if less then 5, replace with a few
    if it is 1, replace with "only one"
    below is my code, I am missing the equating part to replace the numbers could any one of you please help me out fixing this.
    private static String REGEX="(\\d+)";
      private static String INPUT="We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle";
      //String pattern= "(.*)(\\d+)(.*)";
      private static String REPLACE = "replace with many";
      public static void main(String[] args) {
      // Create a Pattern object
           Pattern r = Pattern.compile(REGEX);
        // Now create matcher object.
           Matcher m = r.matcher(INPUT);
           //replace the value 7 by the replace string
    //How to equate the (\\d+)  greater than a number  and use it the below code.
                  INPUT = m.replaceAll(REPLACE);
           //Print the final Result;
            System.out.println(INPUT);
    Thanks and Regards,

    Hi,
    Try the following which makes use of  "appendReplacement" instead with the "start" and "end" methods to locate and check the searched "regExp" string before dynamically setting the "replace" string:
    String regExp = "\\d+";
    String input = "We have 7 tutorials for Java, 2 tutorials for Javascript and 1 tutorial for Oracle";
    String replace;
    Pattern p = Pattern.compile(regExp);
    // get a matcher object
    Matcher m = p.matcher(input);
    StringBuffer sb = new StringBuffer();
    while (m.find()) {
       Integer x = Integer.valueOf(input.substring(m.start(), m.end()));
       replace = (x >= 5) ? "many" : (x == 1) ? "only one" : "few";
       m.appendReplacement(sb, replace);
    m.appendTail(sb);
    System.out.println(sb.toString());
    HTH.
    Regards,
    Rajen
    P.S: Please mark the post as answered/helpful if it resolves your issue for the benefit of all community members.

  • How do I update ios 7 without using itunes and get rid of this message?

    I pressed update and it has a picture message that won't go saying connect to itunes, but I don;t have itunes installed on my laptop! How do I get this to stop as I need my phone?!
    Help would be much appreciated!

    You'll need to install iTunes on your laptop and restore the Phone there.
    There is no way around it.
    itunes.apple.com
    http://support.apple.com/kb/HT1414

  • Can't save suddenly. Got dreaded black x then deleted and redownloaded app and now just get a blank page.  I didn't see anything useful in a forum.  Is this a bug?

    As above....any answers? Thx

    What's make/model of tablet?
    How much storage space do you have left on your device?

  • 10.5.2 and .Mac sync - is this a bug ??

    I just updated from 10.5.1 to 10.5.2 today. Now I get this .Mac sync icon in the top menu. I never have a .Mac account and I certainly do not use the .Mac sync application as such.
    So, why is this icon now showing up in my menu bar? When I click on it, I have two options - Sync Now and Open .Mac Sync Preference which they both don't work. When I try to select 'stop .mac sync' from system preference, it complains I do not have a .mac account.
    How do I get rid of this? This is so frustrating.
    Please help!

    i did a little more research and found a similar thread on this topic. a user named Diana provided a solution by going into iSync.
    if you experience this bug, please check out this thread
    http://discussions.apple.com/thread.jspa?messageID=6578059&#6578059

  • Inserting Records in an Array and using a constructor with it

    I badly need help on this! Please please please! I have been studying java for a short time only.
    Anyway, here goes: My project requires the following:
    Employee inputs the no. of video in the shelf. They have four classifications: Drama, Comedy, Action, and Thriller. Each video classification has different rates. The employee creates a video record containing the following information: 1. video ID number, 2. video classification, and 3. Price.
    The employee should display the classifications of videos available and the price. Only the available video tapes would be displayed according to the customer's chosen classification. When the customer chooses the video he wants to rent, the program will register and attach the name of the customer to the video number.
    I only need to use arrays, and NOT database to record the information.

    is it ok i i declare the drama_rate outside the video class?
    i have a list of variables on my videoupdate classYes. It's probably best to declare it static & then you can access it directly:
    public static float drama_rate = 100.0;
    rate = <the class name>.drama_rate;
    so, i should also include a customer no. both in the video and customer class.I would. You may want to list a bunch of videos and who currently has them. This way you don't have to search the customers AND the videos to do this.
    thanks =) i don't know either why we had to validate/invalidate,\
    but our applet doesnt refresh when >it is supposed to, so
    we just used this method. It wouldnt slow down the application, would it?Could you just revalidate()?
    the use of arrays. i havent finished with the program yet.
    i have the design already, i just couldnt put it in code.
    im not familiar with the use of multidimensional arrays-
    can i use this for the video and customer records i will need to store?Not sure what you're using arrays for, but here's an example of something I might do. Maybe it will be useful to you.
    Have you looked at HashMaps? You could use "Customer" as the key and then use an ArrayList of checked out Videos as the value:
    HashMap customers = new HashMap();
    ArrayList videos = new ArrayList();
    //Add the checked out videos to the list
    videos.add(video);
    <etc>
    // Add this customer and the list of videos he has checked out.
    customers.put(customer,videos);
    [\code]

Maybe you are looking for

  • F110 - Calculation of Debit/Credit in the payment proposal

    The requirement is to be able to process all of the documents for the same vendor for the same paying company code together in one payment document. Separate payment documents are issued for all company code payment transactions, including documents

  • Email sending: "sending report output directly to the body of the email"

    Hi      I got one requirement.this is the enhancement to already exisitng report.when user clicks on send email check box,report has to be display and this report output has to be send to email of the particular vendor. it has be seen directly in the

  • Validating XML against XSD

    Hi, I would like to validate XML against XSD using SAX parser. Can any one help, where I can get information. I could get some information of XML validation against DTD. But could not get much information for XSD validation. Which parser is good for

  • Error when syncing iTunes 8 with iphone 3GS "Notes"

    "iTunes could not sync notes to 'Scott's iPhone' because the iPhone is disconnected" Have tried rebooting, checking/unchecking notes box, etc but I keep getting this error message. Everything else seems to sync fine. Also, I'm unable to even use "not

  • Move tool and command key in photoshop 2014.2 is driving me mad

    Hi all, I'm extremely frustrated with the new move tool in the 2014.2 update. I can no longer able to isolate a selected layer and move it about by holding down command key. Instead every time by holding down command key (while move tool is selected)