Skip to content

Commit

Permalink
[VCM] set reencoding quality to 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyoyuppe committed Apr 14, 2021
1 parent 616249e commit ca8bf43
Showing 1 changed file with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,30 @@ bool ReencodeJPGImage(BYTE* imageBuf, const DWORD imageSize, DWORD& reencodedSiz
OK_OR_BAIL(CreateStreamOnHGlobal(nullptr, true, &outputStream));
OK_OR_BAIL(encoder->Initialize(outputStream.get(), WICBitmapEncoderNoCache));
wil::com_ptr_nothrow<IWICBitmapFrameEncode> encodedFrame;
OK_OR_BAIL(encoder->CreateNewFrame(&encodedFrame, nullptr));
OK_OR_BAIL(encodedFrame->Initialize(nullptr));
wil::com_ptr_nothrow<IPropertyBag2> encoderOptions;
OK_OR_BAIL(encoder->CreateNewFrame(&encodedFrame, &encoderOptions));

ULONG nProperties = 0;
OK_OR_BAIL(encoderOptions->CountProperties(&nProperties));
for (ULONG propIdx = 0; propIdx < nProperties; ++propIdx)
{
PROPBAG2 propBag{};
ULONG _;
OK_OR_BAIL(encoderOptions->GetPropertyInfo(propIdx, 1, &propBag, &_));
if (propBag.pstrName == std::wstring_view{ L"ImageQuality" })
{
wil::unique_variant variant;
variant.vt = VT_R4;
variant.fltVal = 0.1f;
OK_OR_BAIL(encoderOptions->Write(1, &propBag, &variant));
LOG("Successfully set jpg compression quality");
// skip the rest of the properties
propIdx = nProperties;
}
CoTaskMemFree(propBag.pstrName);
}

OK_OR_BAIL(encodedFrame->Initialize(encoderOptions.get()));
WICPixelFormatGUID intermediateFormat = GUID_WICPixelFormat24bppRGB;

OK_OR_BAIL(encodedFrame->SetPixelFormat(&intermediateFormat));
Expand Down

1 comment on commit ca8bf43

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misspellings found, please review:

  • filepath
  • Reencode
  • reencoded
  • seekg
  • streampos
  • tellg
To accept these changes, run the following commands from this repository on this branch
pushd $(git rev-parse --show-toplevel)
perl -e '
my $new_expect_file=".github/actions/spell-check/expect.txt";
use File::Path qw(make_path);
make_path ".github/actions/spell-check";
open FILE, q{<}, $new_expect_file; chomp(my @words = <FILE>); close FILE;
my @add=qw('"filepath Reencode reencoded seekg streampos tellg "');
my %items; @items{@words} = @words x (1); @items{@add} = @add x (1);
@words = sort {lc($a) cmp lc($b)} keys %items;
open FILE, q{>}, $new_expect_file; for my $word (@words) { print FILE "$word\n" if $word =~ /\w/; };
close FILE;'
popd

Please sign in to comment.