Skip to content

Commit 0368a6b

Browse files
HannesWellHeikoKlare
authored andcommitted
Unify ImageLoader implementations and extract differences
Extract existing differences in the ImageLoader implementation for Linux/GTK into an InternalImageFileLoader class that also exists for Windows and MacOS but just delegates to FileFormat.
1 parent f30bf72 commit 0368a6b

File tree

6 files changed

+437
-1036
lines changed

6 files changed

+437
-1036
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2025, 2025 Hannes Wellmann and others.
3+
*
4+
* This program and the accompanying materials
5+
* are made available under the terms of the Eclipse Public License 2.0
6+
* which accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Hannes Wellmann - initial API and implementation
13+
*******************************************************************************/
14+
package org.eclipse.swt.graphics;
15+
16+
import java.io.*;
17+
18+
import org.eclipse.swt.internal.image.*;
19+
20+
class InternalImageLoader {
21+
22+
static ImageData[] load(InputStream stream, ImageLoader imageLoader) {
23+
return FileFormat.load(stream, imageLoader);
24+
}
25+
26+
static void save(OutputStream stream, int format, ImageLoader imageLoader) {
27+
FileFormat.save(stream, format, imageLoader);
28+
}
29+
}

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/ImageLoader.java renamed to bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -10,15 +10,14 @@
1010
*
1111
* Contributors:
1212
* IBM Corporation - initial API and implementation
13+
* Hannes Wellmann - Unify ImageLoader implementations and extract differences into InternalImageLoader
1314
*******************************************************************************/
1415
package org.eclipse.swt.graphics;
1516

16-
1717
import java.io.*;
1818
import java.util.*;
1919

2020
import org.eclipse.swt.*;
21-
import org.eclipse.swt.internal.image.*;
2221

2322
/**
2423
* Instances of this class are used to load images from,
@@ -151,7 +150,7 @@ void reset() {
151150
public ImageData[] load(InputStream stream) {
152151
if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
153152
reset();
154-
data = FileFormat.load(stream, this);
153+
data = InternalImageLoader.load(stream, this);
155154
return data;
156155
}
157156

@@ -217,7 +216,7 @@ public ImageData[] load(String filename) {
217216
*/
218217
public void save(OutputStream stream, int format) {
219218
if (stream == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
220-
FileFormat.save(stream, format, this);
219+
InternalImageLoader.save(stream, format, this);
221220
}
222221

223222
/**

0 commit comments

Comments
 (0)