How can I change the palette of a BufferedImage
How can I change the palette of a BufferedImage ?
My image uses an IndexColorModel but I want to use a web safe palette.
I can't see a way to make a setColorModel() to my image.
Any ideas ?
Thanks...
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.*;
import javax.imageio.*;
import javax.swing.*;
public class ICMExample extends JComponent {
private BufferedImage original, copy;
private Point mouseLocation = new Point();
public ICMExample(BufferedImage original, BufferedImage copy) {
this.original = original;
this.copy = copy;
addMouseMotionListener(new MouseMotionAdapter(){
public void mouseDragged(MouseEvent e) {
mouseLocation = e.getPoint();
repaint();
public Dimension getPreferredSize() {
return new Dimension(original.getWidth(), original.getHeight());
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.drawRenderedImage(original, null);
Shape oldClip = g2.getClip();
g2.clipRect(0, 0, mouseLocation.x, Integer.MAX_VALUE);
g2.drawRenderedImage(copy, null);
g2.setClip(oldClip);
public static void main(String[] args) throws IOException {
URL url = new URL("http://weblogs.java.net/jag/Image54-large.jpeg");
BufferedImage original = ImageIO.read(url);
JComponent app = new ICMExample(original, makeICMVersion(original));
final JFrame f = new JFrame("Drag mouse over image");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(app);
f.pack();
SwingUtilities.invokeLater(new Runnable(){
public void run() {
f.setLocationRelativeTo(null);
f.setVisible(true);
static BufferedImage makeICMVersion(BufferedImage original) {
int w = original.getWidth();
int h = original.getHeight();
IndexColorModel icm = createICM();
BufferedImage copy = new BufferedImage(w, h, BufferedImage.TYPE_BYTE_INDEXED, icm);
Graphics2D g = copy.createGraphics();
g.drawRenderedImage(original, null);
g.dispose();
return copy;
static IndexColorModel createICM() {
byte MAX = (byte) 255;
byte[] r = {MAX, MAX, MAX, MAX, 0, 0, 0, 0};
byte[] g = {MAX, MAX, 0, 0, MAX, MAX, 0, 0};
byte[] b = {MAX, 0, MAX, 0, MAX, 0, MAX, 0};
return new IndexColorModel(3, 8, r, g, b);
}
Similar Messages
-
How can i change the color of the graph in agreement of the program's condition
Hi,
I am using labview 5.1 in my graduation's project final. (sorry by my english, but i am ina hurry)
How can i change the color of the graph in agreement of the program's condition?
I am developing a VI to control the temperature of termistors,but i have another sensor too.
In a graph i have the situation of the termistors,but i want to change the color of the graph when the sensor is active.
Thanks a lot
Rafael Wajnsztajn - BrasilTo change the color of the line itself, you can use the attribute Plot>>Plot Color.
To change the color of the points, you can use the attribute Cursor>>Cursor Color.
To select the color, you should have a color box constant inside the Numeric>>Additional Numeric Constants palette.
This is all in LV 7.0. I'm not sure how it similar it is in 5.1.
One important thing is to place the attribute node inside a case structure which will execute only when your condition has been filled.
If this didn't help you, I suggest you post the relevant piece of code, or at least an image of it (no BMPs, please).
Try to take over the world! -
How can I change the background color of a chart?
How can I change the default black background color of a chart to white?
Thanks
JohnHello All,
Another (and my preferred method) of bringing up the tools palette is to press
<shift>+<Rt-Click>.
Just another way to do something in LabVIEW!
Travis M
LabVIEW R&D
National Instruments -
How can I change the slide to 8 Radio buttons mutually exclusive?
How can I change the slide to 8 Radio buttons mutually exclusive?
I saw the example in Labview. but it only contains upto 5 radio
buttons. I need 8. How can I change it? Is there any shortcuts?I made this with NI's radio button control found in the boolean palette. Just resize the cluster border, and move the buttons to where you want. To add a button, select one of them, hold down Control and Shift keys, then drag the button to a new location. The button gets duplicated. Do this until you have enough buttons.
Message Edited by tbob on 10-31-2005 01:07 PM
- tbob
Inventor of the WORM Global
Attachments:
RadioButtons.PNG 2 KB -
How can I change the display of Inbox in my iPad's mail app- so that it takes up the whole screen, as opposed to just about one third; the other two thirds display the full text of the selected email?
You can't change the display in the Mail app, if you are holding the iPad in landscape orientation then the left-hand third will be for navigation, and the right-hand two-thirds will be an email. If you hold the iPad in portrait orientation then the navigation section becomes a drop-down section.
-
How can I change the background of a running webpage on my own. Example Facebook I want to change its background color from white to black just in my view, not for all. Cause I really hate some site with white background because as I read for an hour it aches my eyes but not on those with darker background color.
You can use the NoSquint extension to set font sizes (text/page zoom) and text colors on web pages.
*NoSquint: https://addons.mozilla.org/firefox/addon/nosquint/ -
Is it possible to save the screenshot files to a different folder than desktop (that is the default). How can I change the destination folder? Thank you, Sal
To change the screenshot capture location to a new place on your Mac, first think of a location that would serve you properly. We like to place ours in a "Screenshot" folder located inside of the User's "Pictures" folder. To change the location to this new location, open the Terminal and enter the following command:
defaults write com.apple.screencapture location /Users/[u]/Pictures/Screenshots/
Replace "[u]" with the name of the user on your system. Once you have entered this command, let's restart the screen capture utility by restarting the SystemUIServer by entering the following command:
killall SystemUIServer
You can optionally log out and back in instead of entering this second command, thus restarting the SystemUIServer. Once restarted, all screen captures taken from here on out will end up in your /Pictures/Screenshots/ folder in the User's home folder on your Mac. -
How can I change the default apple ID for app store. I bought the macbook from my school when I left and I'm the ID in place of mine is the computer departments one. How can i change it to mine?? Thanks
http://support.apple.com/kb/ht5621
-
When my husband and I first bought our iPhones, I was the only one with an Apple ID (since he never used iTunes). He used my apple id to get apps. Now he has his own ID, but my apple ID email address keeps popping up on his phone when he tries to download an app. We do not want to have all of the same apps on our phones. How can we change the ID on his phone? I already tried going to Settings>iTunes &App Store> and changing the Apple ID to his account email and that did not solve the problem. To make things worse, I recently changed my Apple ID email address (without getting a new ID) and I do not remember my old password (and this is the address that is popping up on his phone). He does not have any music on his phone and all of the Apps that he has are free. Any help you could offer would be great (-:
All apps are forever tied to the Apple ID that bought them. To stop your id from popping up, you need to delete the apps on his phone, and then repurchase them under his account.
-
I have both Photoshop 4 and Photoshop 6 on my computer. When I am in Bridge and want to open an image by double clicking, it automatically opens in 6. I see, when I go to "open with" 6 is listed as "default" How can I change the default to open an image with a double click in 4?
You can associate files from the Bridge level and the Desktop level.
In Bridge CS4, go to Preferences > File Type Associations and change it to Photoshop CS4 for the file types you want.
If you want to open files from the Windows Desktop in CS4, these are the instructions:
Do this from the Windows Desktop:
If you want your image file to open in Photoshop and it doesn't, right click on it and choose
Open with > Choose default program… select Photoshop CS4 or CS6 and checkmark "always use the selected program to open this type of file". -
How can we change the password in the iBook donated to our nonprofit? No password was given with the iBook and every time we try to install items, the password window pops up. We need to put in printer and other software. Help! We can use the laptop without changing the password.
If you did not get an OS X install-restore DVD with the computer you may need
to buy one from somewhere, and you may be lucky to get a retail OS X 10.5.x
version. The original grey-label install set of software and OS X it shipped with
likely would be an older system than Leopard 10.5. Last versions of G4 Mac, &
G5, shipped with a Tiger 10.4 system; so did early Intel-based Mac. Grey discs
which accompanied other computer build models generally do not interchange.
The last OS X version a PowerPC architecture can use, if supported, is 10.5.8.
A PPC processor at 867MHz & faster should be able to run OS X 10.5 Leopard.
{With the correct disc installer, you can use it to change a password and other
things including re-install, and perform disk utility functions, etc.}
There is a chance you may be able to get a white-label Replacement 10.4 DVD
or Replacement 10.5 DVD from AppleCare or the online Apple Store (800myapple)
from a Mac OS X system specialist; these have been available yet hard to get
as not all persons involved with them seem to know if they still exist until someone
is asking. These aren't retail stock, are special discs for computers who could use
a system later than original old discs; these are complete install discs not for one
specific series of Mac. Generally they'd work in supported PowerPC G4/G5; but
do not replace specialized original install DVD, such as an early Intel mac requires.
You'd need to have a serial number of the computer, and a method of payment
when seeking some replacement system media from Applecare or Apple sales
and these discs are not available in a retail store. The original Retail discs are
labeled differently and shipped in a retail box with a big X on the front. Other
sources for retail 10.4 Tiger or 10.5 Leopard may be online via amazon sellers
or computer resellers who handle repaired Macs. Avoid mystery grey label ones
that were intended to be sold and kept with their original computer kits.
Good luck! -
How can i change the email address for Icloud on my Iphone 4
I have inherited my wife's Iphone 4 when she upgraded to Iphone 5. The Icloud on the Iphone 4 is tied to her Apple ID. How can I change the Iphone 4 to my Apple ID? Thanks for any help.
For iCloud you go to Settings>iCloud and sign out and sign in with your iCloud account.
There are also many other setting that can be associated with here Apple ID like the following:
- Settings>iTunes & App Stores (sign out and sign in)
- Setting Mail
- Setting Messages and Settings>Facetime Add your own ID/email address and delete hers -
How can I change the name of item in TableViewController iOS
How can I change the name of item in TableViewController? I want to be able to change the title of an item if I added one. Code:
// ViewController.m
// Movie List
// Created by Damian on 20/02/15.
// Copyright (c) 2015 Tika Software. All rights reserved.
#import "ViewController.h"
@interface ViewController ()
These outlets to the buttons use a `strong` reference instead of `weak` because we want
to keep the buttons around even if they're not inside a view.
@property (nonatomic, strong) IBOutlet UIBarButtonItem *editButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *cancelButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *deleteButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem *addButton;
// A simple array of strings for the data model.
@property (nonatomic, strong) NSMutableArray *dataArray;
@end
#pragma mark -
@implementation ViewController
- (void)viewDidLoad
[super viewDidLoad];
This option is also selected in the storyboard. Usually it is better to configure a table view in a xib/storyboard, but we're redundantly configuring this in code to demonstrate how to do that.
self.tableView.allowsMultipleSelectionDuringEditing = YES;
// populate the data array with some example objects
self.dataArray = [NSMutableArray new];
NSString *itemFormatString = NSLocalizedString(@"Movie %d", @"Format string for item");
for (unsigned int itemNumber = 1; itemNumber <= 0; itemNumber++)
NSString *itemName = [NSString stringWithFormat:itemFormatString, itemNumber];
[self.dataArray addObject:itemName];
// make our view consistent
[self updateButtonsToMatchTableState];
#pragma mark - UITableViewDelegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
return self.dataArray.count;
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
// Update the delete button's title based on how many items are selected.
[self updateDeleteButtonTitle];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
// Update the delete button's title based on how many items are selected.
[self updateButtonsToMatchTableState];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
// Configure a cell to show the corresponding string from the array.
static NSString *kCellID = @"cellID";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellID];
cell.textLabel.text = [self.dataArray objectAtIndex:indexPath.row];
return cell;
#pragma mark - Action methods
- (IBAction)editAction:(id)sender
[self.tableView setEditing:YES animated:YES];
[self updateButtonsToMatchTableState];
- (IBAction)cancelAction:(id)sender
[self.tableView setEditing:NO animated:YES];
[self updateButtonsToMatchTableState];
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
// The user tapped one of the OK/Cancel buttons.
if (buttonIndex == 0)
// Delete what the user selected.
NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
BOOL deleteSpecificRows = selectedRows.count > 0;
if (deleteSpecificRows)
// Build an NSIndexSet of all the objects to delete, so they can all be removed at once.
NSMutableIndexSet *indicesOfItemsToDelete = [NSMutableIndexSet new];
for (NSIndexPath *selectionIndex in selectedRows)
[indicesOfItemsToDelete addIndex:selectionIndex.row];
// Delete the objects from our data model.
[self.dataArray removeObjectsAtIndexes:indicesOfItemsToDelete];
// Tell the tableView that we deleted the objects
[self.tableView deleteRowsAtIndexPaths:selectedRows withRowAnimation:UITableViewRowAnimationAutomatic];
else
// Delete everything, delete the objects from our data model.
[self.dataArray removeAllObjects];
// Tell the tableView that we deleted the objects.
// Because we are deleting all the rows, just reload the current table section
[self.tableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationAutomatic];
// Exit editing mode after the deletion.
[self.tableView setEditing:NO animated:YES];
[self updateButtonsToMatchTableState];
- (IBAction)deleteAction:(id)sender
// Open a dialog with just an OK button.
NSString *actionTitle;
if (([[self.tableView indexPathsForSelectedRows] count] == 1)) {
actionTitle = NSLocalizedString(@"Are you sure you want to remove this movie?", @"");
else
actionTitle = NSLocalizedString(@"Are you sure you want to remove these movies?", @"");
NSString *cancelTitle = NSLocalizedString(@"Cancel", @"Cancel title for item removal action");
NSString *okTitle = NSLocalizedString(@"OK", @"OK title for item removal action");
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:actionTitle
delegate:self
cancelButtonTitle:cancelTitle
destructiveButtonTitle:okTitle
otherButtonTitles:nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
// Show from our table view (pops up in the middle of the table).
[actionSheet showInView:self.view];
- (IBAction)addAction:(id)sender
[self.dataArray addObject:@"New Movie"];
// Tell the tableView about the item that was added.
NSIndexPath *indexPathOfNewItem = [NSIndexPath indexPathForRowself.dataArray.count - 1) inSection:0];
[self.tableView insertRowsAtIndexPaths:@[indexPathOfNewItem]
withRowAnimation:UITableViewRowAnimationAutomatic];
// Tell the tableView we have finished adding or removing items.
[self.tableView endUpdates];
// Scroll the tableView so the new item is visible
[self.tableView scrollToRowAtIndexPath:indexPathOfNewItem
atScrollPosition:UITableViewScrollPositionBottom
animated:YES];
// Update the buttons if we need to.
[self updateButtonsToMatchTableState];
#pragma mark - Updating button state
- (void)updateButtonsToMatchTableState
if (self.tableView.editing)
// Show the option to cancel the edit.
self.navigationItem.rightBarButtonItem = self.cancelButton;
[self updateDeleteButtonTitle];
// Show the delete button.
self.navigationItem.leftBarButtonItem = self.deleteButton;
else
// Not in editing mode.
self.navigationItem.leftBarButtonItem = self.addButton;
// Show the edit button, but disable the edit button if there's nothing to edit.
if (self.dataArray.count > 0)
self.editButton.enabled = YES;
else
self.editButton.enabled = NO;
self.navigationItem.rightBarButtonItem = self.editButton;
- (void)updateDeleteButtonTitle
// Update the delete button's title, based on how many items are selected
NSArray *selectedRows = [self.tableView indexPathsForSelectedRows];
BOOL allItemsAreSelected = selectedRows.count == self.dataArray.count;
BOOL noItemsAreSelected = selectedRows.count == 0;
if (allItemsAreSelected || noItemsAreSelected)
self.deleteButton.title = NSLocalizedString(@"Delete All", @"");
else
NSString *titleFormatString =
NSLocalizedString(@"Delete (%d)", @"Title for delete button with placeholder for number");
self.deleteButton.title = [NSString stringWithFormat:titleFormatString, selectedRows.count];
@endHey JB001,
Sounds like you have more going on than just a simple issue with Home Sharing and more dealing with Wi-Fi syncing. Start with the article below and see if that may resolve it.
iTunes 10.5 and later: Troubleshooting iTunes Wi-Fi syncing
http://support.apple.com/kb/TS4062
If it does not work out, then may I suggest contacting Apple for further assistance to walk you through it or just take that time that you were talking about to sort it out.
Contact Apple Support
https://getsupport.apple.com/GetproductgroupList.action
Regards,
-Norm G. -
How can I change the settings wit mail so that when I delete my Verizon email from my iPhone it will also delete from my iPad too.... Seems like I shouldn't have to delete my email in three places...iPhone ..iPad ...and desktop
Don't know which email host you are using, but if this is a POP account, you can't do it. If IMAP, then deleting one email should delete it on all other devices.
-
How can I change the pitch of a track?
In Garageband 10.03, how can I change the pitch of a track?
It seems that I somehow mistakenly changed the pitch of a guitar track I had recorded, so that al the notes in the track sound like they're about an octave too high.
I don't know how I did that, and how to make the pitch slider appear so that I can try to lower the pitch.
I saw three Youtube videos that show how to change a track's pitch by using the pitch slider, but none of them explain how to make the pitch slider appear.
The pitch slider is supposed to appear in the lower, left corner of my window, but it doesn't appear in my window. Instead the lower, left corner of my window says things like, Region, Notes, Time Quantize, Strength and Transpose.There's much to learn in Garageband!
If you want a comprehensive introduction to the new GarageBand, have a look at Edgar Rothermich's book:
Edgar's "GarageBand 10.0 How it Works" explains it very well with many screenshots. You can buy it as iBook from the Book store, as PDF, or as printed book from Amazon, Only, this version of the manual has been written for GarageBand 10.0.1, Some features have changed slightly since then.
http://www.dingdingmusic.com/DingDing/Manuals.html
Maybe you are looking for
-
Had the iphone 3G for about a week now, and love it, but just got a couple of questions as there is no manual as such. 1. Can iphone 3G downlaod adobe acrobat/pdf reader/word (pages) or numbers) to see attachements? 2. Alot of video content on google
-
I have a 2008 Airport Extreme and it's signal is too weak to reach the back of the house. Will the laterst version AE fix that problem? Thanks, windancertoo2354
-
Songs somtimes load out of order.
When I load a new album into itunes, it will make a new album folder for certain songs, so if you look at album flow view the album will be listed 1, 2 or more times with most songs on first album then maybe song 7 on album 2 and song 12 on album thr
-
Cisco 526 WLC and 2106 WLC in one Mobility Group
Hi, is it possbile to build a solution with one Cisco 526 Wireless Express Mobility Controller and one Cisco 2106 Wireless LAN Controller in one Mobility Group regarding seamless roaming?? Thank for your answers Best regards Stephan
-
How to invoke the Cash Drawer to be open by java code.
hi friends, how to invoke the Cash Drawer and display pole to be open by java code. pls help me out.