SetBlendMode
IPDFDocument4 :: Transparency

See Also Example
Collapse All

This method sets the blend mode - the way the backdrop and source colors are combined into a resulting color.

Syntax

HRESULT SetBlendMode (
BlendMode mode
)
Parameters
mode
Blend mode

Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Example

Using Blend Mode

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }

{ Declaration:

  const
    blendModeNames: array[0..15] of PChar = (
      'Normal', 'Multiply', 'Screen', 'Overlay', 'Darken', 'Lighten',
      'ColorDodge', 'ColorBurn', 'HardLight', 'SoftLight', 'Difference',
      'Exclusion', 'Hue', 'Saturation', 'Color', 'Luminosity');
  var
    fLeft, fTop, fWidth, fHeight : Single;
    rowShift, columnShift : Single;
    row, column : integer;
}

fLeft := 50.0;
fTop := 50.0;
fWidth := 50.0;
fHeight := 50.0;

for row := 0 to 2 do
begin
    rowShift := row * height * 2;
    for column := 0 to 4 do
    begin
        PDF.SetBlendMode(bmNormal);
        columnShift := column * (fWidth * 1.5);

        PDF.SetColorFill(0, 0, 0, 0);
        PDF.ShowTextAt(fLeft + columnShift, fTop + rowShift - 20, blendModeNames[column + 5 * row]);

        PDF.SetColorFill(0.9, 0.6, 0.1, 0);
        PDF.DrawRectangle(fLeft + columnShift, fTop + rowShift, fWidth, fHeight, 0);
        PDF.Fill;

        PDF.SetBlendMode(column + 5 * row);

        PDF.SetColorFill(0.5, 0.5, 1.0, 0);
        PDF.DrawRectangle(fLeft + columnShift + fWidth / 3, fTop + rowShift + fHeight / 3, fWidth, fHeight, 0);
        PDF.Fill;
    end;
end;

PDF.SaveToFile('TestBlendModes.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created

string blendModeNames[] = { "Normal", "Multiply", "Screen", "Overlay",
    "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight",
    "Difference", "Exclusion", "Hue", "Saturation", "Color", "Luminosity" };

float fLeft = 50.0f;
float fTop = 50.0f;
float fWidth = 50.0f;
float fHeight = 50.0f;

for (int row = 0; row < 3; row++)
{
    float rowShift = row * height * 2;
    for (int column = 0; column < 5; column++)
    {
        PDF->SetBlendMode(bmNormal);

        float columnShift = column * (fWidth * 1.5f);

        PDF->SetColorFill(0, 0, 0, 0);
        PDF->ShowTextAt(fLeft + columnShift, fTop + rowShift - 20, blendModeNames[column + 5 * row]);

        PDF->SetColorFill(0.9f, 0.6f, 0.1f, 0);
        PDF->DrawRectangle(fLeft + columnShift, fTop + rowShift, fWidth, fHeight, 0);
        PDF->Fill();

        PDF->SetBlendMode((BlendMode)(column + 5 * row));

        PDF->SetColorFill(0.5f, 0.5f, 1.0f, 0);
        PDF->DrawRectangle(fLeft + columnShift + fWidth / 3, fTop + rowShift + fHeight / 3, fWidth, fHeight, 0);
        PDF->Fill();
    }
}

PDF->SaveToFile("TestBlendModes.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created

string[] blendModeNames = new string[] { "Normal", "Multiply", "Screen", "Overlay",
    "Darken", "Lighten", "ColorDodge", "ColorBurn", "HardLight", "SoftLight",
    "Difference", "Exclusion", "Hue", "Saturation", "Color", "Luminosity" };

BlendMode[] blendModes = new BlendMode[] { BlendMode.bmNormal, BlendMode.bmMultiply, BlendMode.bmScreen,
    BlendMode.bmOverlay, BlendMode.bmDarken, BlendMode.bmLighten, BlendMode.bmColorDodge,
    BlendMode.bmColorBurn, BlendMode.bmHardLight, BlendMode.bmSoftLight, BlendMode.bmDifference,
    BlendMode.bmExclusion, BlendMode.bmHue, BlendMode.bmSaturation, BlendMode.bmColor, BlendMode.bmLuminosity };

float fLeft = 50.0f;
float fTop = 50.0f;
float fWidth = 50.0f;
float fHeight = 50.0f;

for (int row = 0; row < 3; row++)
{
    float rowShift = row * fHeight * 2;
    for (int column = 0; column < 5; column++)
    {
        PDF.SetBlendMode(BlendMode.bmNormal);
        float columnShift = column * (fWidth * 1.5f);

        PDF.SetColorFill(0, 0, 0, 0);
        PDF.ShowTextAt(fLeft + columnShift, fTop + rowShift - 20, blendModeNames[column + 5 * row]);

        PDF.SetColorFill(0.9f, 0.6f, 0.1f, 0);
        PDF.DrawRectangle(fLeft + columnShift, fTop + rowShift, fWidth, fHeight, 0);
        PDF.Fill();

        PDF.SetBlendMode(blendModes[column + 5 * row]);

        PDF.SetColorFill(0.5f, 0.5f, 1.0f, 0);
        PDF.DrawRectangle(fLeft + columnShift + fWidth / 3, fTop + rowShift + fHeight / 3, fWidth, fHeight, 0);
        PDF.Fill();
    }
}

PDF.SaveToFile("TestBlendModes.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created

Dim blendModeNames(16)
blendModeNames(1) = "Normal"
blendModeNames(2) = "Multiply"
blendModeNames(3) = "Screen"
blendModeNames(4) = "Overlay"
blendModeNames(5) = "Darken"
blendModeNames(6) = "Lighten"
blendModeNames(7) = "ColorDodge"
blendModeNames(8) = "ColorBurn"
blendModeNames(9) = "HardLight"
blendModeNames(10) = "SoftLight"
blendModeNames(11) = "Difference"
blendModeNames(12) = "Exclusion"
blendModeNames(13) = "Hue"
blendModeNames(14) = "Saturation"
blendModeNames(15) = "Color"
blendModeNames(16) = "Luminosity"

fLeft = 50
fTop = 50
fWidth = 50
fHeight = 50

for row = 0 To 2
    rowShift = row * fHeight * 2
    for column = 0 To 4
        PDF.SetBlendMode 0' bmNormal
        columnShift = column * (fWidth * 1.5)

        PDF.SetColorFill 0, 0, 0, 0
        PDF.ShowTextAt fLeft + columnShift, fTop + rowShift - 20, blendModeNames(column + 5 * row + 1)

        PDF.SetColorFill 0.9, 0.6, 0.1, 0
        PDF.DrawRectangle fLeft + columnShift, fTop + rowShift, fWidth, fHeight, 0
        PDF.Fill

        PDF.SetBlendMode column + 5 * row

        PDF.SetColorFill 0.5, 0.5, 1.0, 0
        PDF.DrawRectangle fLeft + columnShift + fWidth / 3, fTop + rowShift + fHeight / 3, fWidth, fHeight, 0
        PDF.Fill
    next
next

PDF.SaveToFile "TestBlendModes.pdf", true

See Also

Reference