2013-05-12 6 views
0

레티 나 기기에서는 기본적으로 이미지 업 스케일을 알고 있지만 기본 배율은 이미지를 흐리게 만듭니다.레티 나 기기의 이미지 업 스케일

가장 가까운 이웃 모드에서 투명한 픽셀을 만들지 만, 각 픽셀에 4를 곱한 방법이 있는지 궁금 해서요. 그래서 망막이 아닌 장치에서와 같이 보입니다.

내가 말하는 내용은 아래 이미지에서 볼 수 있습니다. example http://cclloyd.com/downloads/sdfsdf.png

답변

0

CoreGraphics는 2x 스케일을 사용하지 않으므로 이와 같은 작업을 수행하기 위해 명시 적 픽셀 매핑 논리를 작성해야합니다. 다음은이 작업을 수행하는 데 사용한 일부 코드입니다. 물론 입력 버퍼를 픽셀로 사용하고 픽셀 크기가 2 배 큰 출력 버퍼에 쓰기 때문에 세부 사항을 채울 필요가 있습니다.

// Use special case "DOUBLE" logic that will simply duplicate the exact 
    // RGB value from the indicated pixel into the 2x sized output buffer. 

    int numOutputPixels = resizedFrameBuffer.width * resizedFrameBuffer.height; 

    uint32_t *inPixels32 = (uint32_t*)cgFrameBuffer.pixels; 
    uint32_t *outPixels32 = (uint32_t*)resizedFrameBuffer.pixels; 

    int outRow = 0; 
    int outColumn = 0; 

    for (int i=0; i < numOutputPixels; i++) { 
    if ((i > 0) && ((i % resizedFrameBuffer.width) == 0)) { 
     outRow += 1; 
     outColumn = 0; 
    } 

    // Divide by 2 to get the column/row in the input framebuffer 
    int inColumn = outColumn/2; 
    int inRow = outRow/2; 

    // Get the pixel for the row and column this output pixel corresponds to 
    int inOffset = (inRow * cgFrameBuffer.width) + inColumn; 
    uint32_t pixel = inPixels32[inOffset]; 

    outPixels32[i] = pixel; 

    //fprintf(stdout, "Wrote 0x%.10X for 2x row/col %d %d (%d), read from row/col %d %d (%d)\n", pixel, outRow, outColumn, i, inRow, inColumn, inOffset); 

    outColumn += 1; 
    } 

물론이 코드는 픽셀 버퍼를 만든 다음 다시 CFImageRef로 래핑하는 방법에 따라 달라집니다. 그러나, 당신은 쉽게 그런 종류의 일을하는 모든 코드를 찾을 수 있습니다.