gdiplus: Add tests for interpolation mode and make them pass.
This commit is contained in:
parent
b3c333e916
commit
a2631ae1d2
|
@ -1364,7 +1364,7 @@ GpStatus WINGDIPAPI GdipCreateFromHDC2(HDC hdc, HANDLE hDevice, GpGraphics **gra
|
|||
(*graphics)->owndc = FALSE;
|
||||
(*graphics)->smoothing = SmoothingModeDefault;
|
||||
(*graphics)->compqual = CompositingQualityDefault;
|
||||
(*graphics)->interpolation = InterpolationModeDefault;
|
||||
(*graphics)->interpolation = InterpolationModeBilinear;
|
||||
(*graphics)->pixeloffset = PixelOffsetModeDefault;
|
||||
(*graphics)->compmode = CompositingModeSourceOver;
|
||||
(*graphics)->unit = UnitDisplay;
|
||||
|
@ -1403,7 +1403,7 @@ GpStatus graphics_from_image(GpImage *image, GpGraphics **graphics)
|
|||
(*graphics)->image = image;
|
||||
(*graphics)->smoothing = SmoothingModeDefault;
|
||||
(*graphics)->compqual = CompositingQualityDefault;
|
||||
(*graphics)->interpolation = InterpolationModeDefault;
|
||||
(*graphics)->interpolation = InterpolationModeBilinear;
|
||||
(*graphics)->pixeloffset = PixelOffsetModeDefault;
|
||||
(*graphics)->compmode = CompositingModeSourceOver;
|
||||
(*graphics)->unit = UnitDisplay;
|
||||
|
@ -4638,12 +4638,18 @@ GpStatus WINGDIPAPI GdipSetInterpolationMode(GpGraphics *graphics,
|
|||
{
|
||||
TRACE("(%p, %d)\n", graphics, mode);
|
||||
|
||||
if(!graphics)
|
||||
if(!graphics || mode == InterpolationModeInvalid || mode > InterpolationModeHighQualityBicubic)
|
||||
return InvalidParameter;
|
||||
|
||||
if(graphics->busy)
|
||||
return ObjectBusy;
|
||||
|
||||
if (mode == InterpolationModeDefault || mode == InterpolationModeLowQuality)
|
||||
mode = InterpolationModeBilinear;
|
||||
|
||||
if (mode == InterpolationModeHighQuality)
|
||||
mode = InterpolationModeHighQualityBicubic;
|
||||
|
||||
graphics->interpolation = mode;
|
||||
|
||||
return Ok;
|
||||
|
|
|
@ -3012,6 +3012,75 @@ static void test_string_functions(void)
|
|||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
static void test_get_set_interpolation(void)
|
||||
{
|
||||
GpGraphics *graphics;
|
||||
HDC hdc = GetDC( hwnd );
|
||||
GpStatus status;
|
||||
InterpolationMode mode;
|
||||
|
||||
ok(hdc != NULL, "Expected HDC to be initialized\n");
|
||||
status = GdipCreateFromHDC(hdc, &graphics);
|
||||
expect(Ok, status);
|
||||
ok(graphics != NULL, "Expected graphics to be initialized\n");
|
||||
|
||||
status = GdipGetInterpolationMode(NULL, &mode);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
if (0)
|
||||
{
|
||||
/* Crashes on Windows XP */
|
||||
status = GdipGetInterpolationMode(graphics, NULL);
|
||||
expect(InvalidParameter, status);
|
||||
}
|
||||
|
||||
status = GdipSetInterpolationMode(NULL, InterpolationModeNearestNeighbor);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
/* out of range */
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeHighQualityBicubic+1);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeInvalid);
|
||||
expect(InvalidParameter, status);
|
||||
|
||||
status = GdipGetInterpolationMode(graphics, &mode);
|
||||
expect(Ok, status);
|
||||
expect(InterpolationModeBilinear, mode);
|
||||
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeNearestNeighbor);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetInterpolationMode(graphics, &mode);
|
||||
expect(Ok, status);
|
||||
expect(InterpolationModeNearestNeighbor, mode);
|
||||
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeDefault);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetInterpolationMode(graphics, &mode);
|
||||
expect(Ok, status);
|
||||
expect(InterpolationModeBilinear, mode);
|
||||
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeLowQuality);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetInterpolationMode(graphics, &mode);
|
||||
expect(Ok, status);
|
||||
expect(InterpolationModeBilinear, mode);
|
||||
|
||||
status = GdipSetInterpolationMode(graphics, InterpolationModeHighQuality);
|
||||
expect(Ok, status);
|
||||
|
||||
status = GdipGetInterpolationMode(graphics, &mode);
|
||||
expect(Ok, status);
|
||||
expect(InterpolationModeHighQualityBicubic, mode);
|
||||
|
||||
GdipDeleteGraphics(graphics);
|
||||
|
||||
ReleaseDC(hwnd, hdc);
|
||||
}
|
||||
|
||||
START_TEST(graphics)
|
||||
{
|
||||
struct GdiplusStartupInput gdiplusStartupInput;
|
||||
|
@ -3070,6 +3139,7 @@ START_TEST(graphics)
|
|||
test_textcontrast();
|
||||
test_fromMemoryBitmap();
|
||||
test_string_functions();
|
||||
test_get_set_interpolation();
|
||||
|
||||
GdiplusShutdown(gdiplusToken);
|
||||
DestroyWindow( hwnd );
|
||||
|
|
Loading…
Reference in New Issue