Skip to content

Commit

Permalink
*) New methods to insert bitmaps that feature transparencies.
Browse files Browse the repository at this point in the history
*) Logo background is transparent now. (Using pixel at (0,0) to determine which color is transparent. Too dirty?)
*) Logo is loaded through filesystem instead of HTTP now.


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4247 6c8d7289-2bf4-0310-a012-ef5d649a1542
  • Loading branch information
low012 committed Dec 4, 2007
1 parent be214e5 commit 76cd6ed
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 13 deletions.
13 changes: 3 additions & 10 deletions htroot/Banner.java
Expand Up @@ -46,26 +46,23 @@

import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaGrafics;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
import de.anomic.ymage.ymageMatrix;
import de.anomic.yacy.yacyCore;
import de.anomic.yacy.yacySeed;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;

/** draw a banner with information about the peer */
public class Banner {

public static ymageMatrix respond(httpHeader header, serverObjects post, serverSwitch env) throws IOException {

final String IMAGE = "env/grafics/yacy.gif";
final String IMAGE = "htroot/env/grafics/yacy.gif";
int width = 468;
int height = 60;
String bgcolor = plasmaGrafics.COL_BACKGROUND;
Expand Down Expand Up @@ -126,11 +123,7 @@ public static ymageMatrix respond(httpHeader header, serverObjects post, serverS
}

if (!plasmaGrafics.logoIsLoaded()) {
plasmaSwitchboard switchboard = (plasmaSwitchboard)env;
int port = serverCore.getPortNr(switchboard.getConfig("port", "8080"));
String host = serverDomains.myPublicLocalIP().getHostAddress();
BufferedImage logo = ImageIO.read(new URL("http://"+host+":"+port+"/"+IMAGE));
//BufferedImage logo = ImageIO.read(new File(IMAGE));
BufferedImage logo = ImageIO.read(new File(IMAGE));
return plasmaGrafics.getBannerPicture(1000, width, height, bgcolor, textcolor, bordercolor, name, links, words, type, myppm, network, nlinks, nwords, nqph, nppm, logo);
}

Expand Down
2 changes: 1 addition & 1 deletion source/de/anomic/plasma/plasmaGrafics.java
Expand Up @@ -396,7 +396,7 @@ private static void drawBannerPicture(int width, int height, String bgcolor, Str
if (logo != null) {
int x = (int)(100/2 - logo.getWidth()/2);
int y = (int)(height/2 - logo.getHeight()/2);
bannerPicture.insertBitmap(logo, x, y);
bannerPicture.insertBitmap(logo, x, y, 0, 0);
}

if (!bordercolor.equals("")) {
Expand Down
35 changes: 33 additions & 2 deletions source/de/anomic/ymage/ymageMatrix.java
Expand Up @@ -264,20 +264,51 @@ public void arcArc(int cx, int cy, int arcRadius, int angle, int innerRadius, in
* @author Marc Nause
*/
public void insertBitmap(BufferedImage bitmap, int x, int y) {
insertBitmap(bitmap, x, y, -1);
}

/**
* inserts an image into the ymageMatrix where all pixels that have the same RGB value as the
* pixel at (xx, yy) are transparent
* @param bitmap the bitmap to be inserted
* @param x the x value of the upper left coordinate in the ymageMatrix where the bitmap will be placed
* @param y the y value of the upper left coordinate in the ymageMatrix where the bitmap will be placed
* @param xx the x value of the pixel that determines which color is transparent
* @param yy the y value of the pixel that determines which color is transparent
* @author Marc Nause
*/
public void insertBitmap(BufferedImage bitmap, int x, int y, int xx, int yy) {
insertBitmap(bitmap, x, y, bitmap.getRGB(xx, yy));
}

/**
* inserts an image into the ymageMatrix where all pixels that have a special RGB value
* pixel at (xx, yy) are transparent
* @param bitmap the bitmap to be inserted
* @param x the x value of the upper left coordinate in the ymageMatrix where the bitmap will be placed
* @param y the y value of the upper left coordinate in the ymageMatrix where the bitmap will be placed
* @param rgb the RGB value that will be transparent
* @author Marc Nause
*/
public void insertBitmap(BufferedImage bitmap, int x, int y, int transRGB) {
int heightSrc = bitmap.getHeight();
int widthSrc = bitmap.getWidth();
int heightTgt = image.getHeight();
int widthTgt = image.getWidth();

int rgb;
for (int i = 0; i < heightSrc; i++) {
for (int j = 0; j < widthSrc; j++) {
// pixel in legal area?
if (j+x >= 0 && i+y >= 0 && i+y < heightTgt && j+x < widthTgt) {
image.setRGB(j+x, i+y, bitmap.getRGB(j, i));
rgb = bitmap.getRGB(j, i);
if (rgb != transRGB) {
image.setRGB(j+x, i+y, rgb);
}
}
}
}
}
}

public static void demoPaint(ymageMatrix m) {
m.setColor(SUBTRACTIVE_CYAN);
Expand Down

0 comments on commit 76cd6ed

Please sign in to comment.