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 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
397 hr = piBitmapFrameEncode->Initialize(piPropertybag.get()); | 397 hr = piBitmapFrameEncode->Initialize(piPropertybag.get()); |
398 } | 398 } |
399 | 399 |
400 //Set the size of the frame. | 400 //Set the size of the frame. |
401 const UINT width = bitmap->width(); | 401 const UINT width = bitmap->width(); |
402 const UINT height = bitmap->height(); | 402 const UINT height = bitmap->height(); |
403 if (SUCCEEDED(hr)) { | 403 if (SUCCEEDED(hr)) { |
404 hr = piBitmapFrameEncode->SetSize(width, height); | 404 hr = piBitmapFrameEncode->SetSize(width, height); |
405 } | 405 } |
406 | 406 |
407 //Set the pixel format of the frame. | 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 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA; | 409 const WICPixelFormatGUID formatDesired = GUID_WICPixelFormat32bppBGRA; |
409 WICPixelFormatGUID formatGUID = formatDesired; | 410 WICPixelFormatGUID formatGUID = formatDesired; |
410 if (SUCCEEDED(hr)) { | 411 if (SUCCEEDED(hr)) { |
411 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID); | 412 hr = piBitmapFrameEncode->SetPixelFormat(&formatGUID); |
412 } | 413 } |
413 if (SUCCEEDED(hr)) { | |
msarett
2016/03/18 16:41:32
This code block causes the WIC encoder to fail for
| |
414 //Be sure the image format is the one requested. | |
415 hr = IsEqualGUID(formatGUID, formatDesired) ? S_OK : E_FAIL; | |
416 } | |
417 | 414 |
418 //Write the pixels into the frame. | 415 //Write the pixels into the frame. |
419 if (SUCCEEDED(hr)) { | 416 if (SUCCEEDED(hr)) { |
420 SkAutoLockPixels alp(*bitmap); | 417 SkAutoLockPixels alp(*bitmap); |
421 const UINT stride = (UINT) bitmap->rowBytes(); | 418 const UINT stride = (UINT) bitmap->rowBytes(); |
422 hr = piBitmapFrameEncode->WritePixels( | 419 hr = piBitmapFrameEncode->WritePixels( |
423 height | 420 height |
424 , stride | 421 , stride |
425 , stride * height | 422 , stride * height |
426 , reinterpret_cast<BYTE*>(bitmap->getPixels())); | 423 , reinterpret_cast<BYTE*>(bitmap->getPixels())); |
427 } | 424 } |
428 | 425 |
429 if (SUCCEEDED(hr)) { | 426 if (SUCCEEDED(hr)) { |
430 hr = piBitmapFrameEncode->Commit(); | 427 hr = piBitmapFrameEncode->Commit(); |
431 } | 428 } |
432 | 429 |
433 if (SUCCEEDED(hr)) { | 430 if (SUCCEEDED(hr)) { |
434 hr = piEncoder->Commit(); | 431 hr = piEncoder->Commit(); |
435 } | 432 } |
436 | 433 |
437 return SUCCEEDED(hr); | 434 return SUCCEEDED(hr); |
438 } | 435 } |
439 | 436 |
440 /////////////////////////////////////////////////////////////////////////////// | 437 /////////////////////////////////////////////////////////////////////////////// |
441 | 438 /* |
scroggo
2016/03/18 17:23:12
This will disable the encoders on Windows. Is that
| |
442 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { | 439 static SkImageEncoder* sk_imageencoder_wic_factory(SkImageEncoder::Type t) { |
443 switch (t) { | 440 switch (t) { |
444 case SkImageEncoder::kBMP_Type: | 441 case SkImageEncoder::kBMP_Type: |
445 case SkImageEncoder::kICO_Type: | 442 case SkImageEncoder::kICO_Type: |
446 case SkImageEncoder::kJPEG_Type: | 443 case SkImageEncoder::kJPEG_Type: |
447 case SkImageEncoder::kPNG_Type: | 444 case SkImageEncoder::kPNG_Type: |
448 break; | 445 break; |
449 default: | 446 default: |
450 return nullptr; | 447 return nullptr; |
451 } | 448 } |
452 return new SkImageEncoder_WIC(t); | 449 return new SkImageEncoder_WIC(t); |
453 } | 450 } |
454 | 451 |
455 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory); | 452 static SkImageEncoder_EncodeReg gEReg(sk_imageencoder_wic_factory);*/ |
456 | 453 |
457 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { | 454 static SkImageDecoder::Format get_format_wic(SkStreamRewindable* stream) { |
458 SkImageDecoder::Format format; | 455 SkImageDecoder::Format format; |
459 SkImageDecoder_WIC codec; | 456 SkImageDecoder_WIC codec; |
460 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) { | 457 if (!codec.decodeStream(stream, nullptr, SkImageDecoder_WIC::kDecodeFormat_W ICMode, &format)) { |
461 format = SkImageDecoder::kUnknown_Format; | 458 format = SkImageDecoder::kUnknown_Format; |
462 } | 459 } |
463 return format; | 460 return format; |
464 } | 461 } |
465 | 462 |
466 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); | 463 static SkImageDecoder_FormatReg gFormatReg(get_format_wic); |
467 | 464 |
468 #endif // defined(SK_BUILD_FOR_WIN32) | 465 #endif // defined(SK_BUILD_FOR_WIN32) |
OLD | NEW |