-
Notifications
You must be signed in to change notification settings - Fork 187
Callback for dynamic drawing with a GC on images #1734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
HeikoKlare
merged 1 commit into
eclipse-platform:master
from
akoch-yatta:add-gc-image-provider
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageGcDrawer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Yatta and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Yatta - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.swt.graphics; | ||
|
|
||
| /** | ||
| * Interface to provide a callback mechanism to draw on different GC instances | ||
| * depending on the zoom the image will be used for. A common use case is when | ||
| * the application is moved from a low DPI monitor to a high DPI monitor. This | ||
| * provides API which will be called by SWT during the image rendering. | ||
| * | ||
| * This interface needs to be implemented by client code to provide logic that | ||
| * draws on the empty GC on demand. | ||
| * | ||
| * @since 3.129 | ||
| */ | ||
| public interface ImageGcDrawer { | ||
|
|
||
| /** | ||
| * Draws an image on a GC for a requested zoom level. | ||
| * | ||
| * @param gc The GC will draw on the underlying Image and is configured | ||
| * for the targeted zoom | ||
| * @param imageWidth The width of the image in points to draw on | ||
| * @param imageHeight The height of the image in points to draw on | ||
| */ | ||
| void drawOn(GC gc, int imageWidth, int imageHeight); | ||
|
|
||
| /** | ||
| * Executes post processing on ImageData. This method will always be called | ||
| * after <code>drawOn</code> and contain the resulting ImageData. | ||
| * | ||
| * @param imageData The resulting ImageData after <code>drawOn</code> was called | ||
| */ | ||
| default void postProcess(ImageData imageData) { | ||
| } | ||
|
|
||
| } | ||
31 changes: 31 additions & 0 deletions
31
...lipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/TransparencyColorImageGcDrawer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| /******************************************************************************* | ||
| * Copyright (c) 2025 Yatta and others. | ||
| * | ||
| * This program and the accompanying materials | ||
| * are made available under the terms of the Eclipse Public License 2.0 | ||
| * which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-2.0/ | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Contributors: | ||
| * Yatta - initial API and implementation | ||
| *******************************************************************************/ | ||
| package org.eclipse.swt.internal; | ||
|
|
||
| import org.eclipse.swt.graphics.*; | ||
|
|
||
| public abstract class TransparencyColorImageGcDrawer implements ImageGcDrawer { | ||
|
|
||
| private final Color transparencyColor; | ||
|
|
||
| public TransparencyColorImageGcDrawer(Color transparencyColor) { | ||
| this.transparencyColor = transparencyColor; | ||
| } | ||
|
|
||
| @Override | ||
| public void postProcess(ImageData imageData) { | ||
| imageData.transparentPixel = imageData.palette.getPixel(transparencyColor.getRGB()); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.