Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/display/display_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,7 @@ function makePathFromDrawOPS(data) {
export {
applyOpacity,
ColorScheme,
computeLuminance,
CSSConstants,
deprecated,
fetchData,
Expand Down
15 changes: 9 additions & 6 deletions src/display/filter_factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
* limitations under the License.
*/

import {
computeLuminance,
getRGB,
getRGBA,
isDataScheme,
} from "./display_utils.js";
import {
FeatureTest,
SVG_NS,
Expand All @@ -21,7 +27,6 @@ import {
Util,
warn,
} from "../shared/util.js";
import { getRGB, getRGBA, isDataScheme } from "./display_utils.js";

class BaseFilterFactory {
constructor() {
Expand Down Expand Up @@ -277,11 +282,9 @@ class DOMFilterFactory extends BaseFilterFactory {
// Then for every color in the pdf, if its rounded luminance is the
// same as the background one then it's replaced by the new
// background color else by the foreground one.
const map = new Array(256);
for (let i = 0; i <= 255; i++) {
const x = i / 255;
map[i] = x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
}
const map = Array.from({ length: 256 }, (_, i) =>
computeLuminance(i / 255)
);
const table = map.join(",");

const id = `g_${this.#docId}_hcm_filter`;
Expand Down