OLD | NEW |
---|---|
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "SkTypes.h" | 9 #include "SkTypes.h" |
10 | 10 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 hr = piBitmapFrameEncode->SetSize(width, height); | 404 hr = piBitmapFrameEncode->SetSize(width, height); |
405 } | 405 } |
406 | 406 |
407 //Set the pixel format of the frame. If native encoded format cannot match BGRA, | 407 //Set the pixel format of the frame. If native encoded format cannot match BGRA, |
408 //it will choose the closest pixel format that it supports. | 408 //it will choose the closest pixel format that it supports. |
409 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA; | 409 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA; |
410 WICPixelFormatGUID formatGUID = formatDesired; | 410 WICPixelFormatGUID formatGUID = formatDesired; |
411 if (SUCCEEDED(hr)) { | 411 if (SUCCEEDED(hr)) { |
412 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID); | 412 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID); |
413 } | 413 } |
414 if (SUCCEEDED(hr)) { | |
msarett
2016/03/21 20:09:28
Adding back in code that I deleted in https://code
| |
415 //Be sure the image format is the one requested. | |
416 hr = IsEqualGUID(formatGUID, formatDesired) ? S_OK : E_FAIL; | |
417 } | |
414 | 418 |
415 //Write the pixels into the frame. | 419 //Write the pixels into the frame. |
416 if (SUCCEEDED(hr)) { | 420 if (SUCCEEDED(hr)) { |
417 SkAutoLockPixels alp(*bitmap); | 421 SkAutoLockPixels alp(*bitmap); |
418 const UINT stride = (UINT) bitmap->rowBytes(); | 422 const UINT stride = (UINT) bitmap->rowBytes(); |
419 hr = piBitmapFrameEncode->WritePixels( | 423 hr = piBitmapFrameEncode->WritePixels( |
420 height | 424 height |
421 , stride | 425 , stride |
422 , stride * height | 426 , stride * height |
423 , reinterpret_cast<BYTE*>(bitmap->getPixels())); | 427 , reinterpret_cast<BYTE*>(bitmap->getPixels())); |
424 } | 428 } |
425 | 429 |
426 if (SUCCEEDED(hr)) { | 430 if (SUCCEEDED(hr)) { |
427 hr = piBitmapFrameEncode->Commit(); | 431 hr = piBitmapFrameEncode->Commit(); |
428 } | 432 } |
429 | 433 |
430 if (SUCCEEDED(hr)) { | 434 if (SUCCEEDED(hr)) { |
431 hr = piEncoder->Commit(); | 435 hr = piEncoder->Commit(); |
432 } | 436 } |
433 | 437 |
434 return SUCCEEDED(hr); | 438 return SUCCEEDED(hr); |
435 } | 439 } |
436 | 440 |
437 /////////////////////////////////////////////////////////////////////////////// | 441 /////////////////////////////////////////////////////////////////////////////// |
438 | 442 |
439 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { | 443 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { |
440 switch (t) { | 444 switch (t) { |
441 case SkImageEncoder::kBMP_Type: | 445 case SkImageEncoder::kBMP_Type: |
442 case SkImageEncoder::kICO_Type: | 446 case SkImageEncoder::kICO_Type: |
443 case SkImageEncoder::kJPEG_Type: | |
444 case SkImageEncoder::kPNG_Type: | 447 case SkImageEncoder::kPNG_Type: |
445 break; | 448 break; |
446 default: | 449 default: |
447 return nullptr; | 450 return nullptr; |
448 } | 451 } |
449 return new SkImageEncoder_WIC(t); | 452 return new SkImageEncoder_WIC(t); |
450 } | 453 } |
451 | 454 |
452 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory); | 455 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory); |
453 | 456 |
454 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { | 457 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { |
455 SkImageDecoder::Format format; | 458 SkImageDecoder::Format format; |
456 SkImageDecoder_WIC codec; | 459 SkImageDecoder_WIC codec; |
457 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) { | 460 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) { |
458 format = SkImageDecoder::kUnknown_Format; | 461 format = SkImageDecoder::kUnknown_Format; |
459 } | 462 } |
460 return format; | 463 return format; |
461 } | 464 } |
462 | 465 |
463 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); | 466 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); |
464 | 467 |
465 #endif // defined(SK_BUILD_FOR_WIN32) | 468 #endif // defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |