Is this the fastest way to create a single color bufferedImage?

Here is my code but it's slow sometimes. Is there a better way?
BufferedImage bi = new BufferedImage(1600,1200, BufferedImage.TYPE_INT_RGB);
int[] rgbs = new int[1600*1200];
for (int j =0; j<1600*1200; j++)
   rgbs[j] = Color.RED;
bi.setRGB(0,0,1600,1200,rgbs,0,1600);

This will be even faster.
int w = 1600;
int h = 1200;
int masks[] = new int[4];
rv[0] = 0xff0000; // red
rv[1] = 0x00ff00; // green
rv[2] = 0x0000ff; // blue
rv[3] = 0xff000000; // alpha
SampleModel sm = new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT,
                                                  w, h, masks);
final int rawData[] = new int[w * h];
DataBufferInt db = new DataBufferInt(rawData, rawData.length);
WritableRaster ras = Raster.createWritableRaster(sm, db, null);
ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
ColorModel cm = new DirectColorModel(cs, 32, masks[0], masks[1],
                                     masks[2], masks[3],
                                     false,
                                     DataBuffer.TYPE_INT);
BufferedImage  img = new BufferedImage(cm, ras, false, null);
int value = 0xffff0000; // opaque red.
int l = rawData.length;
// Set the image to solid color of the value
for(int i = 0; i < rawData.length; i++)
    rawData[i] = value;

Similar Messages

  • Is this the fastest way to copy files?

    I'm looking for a way to take 1 file and make many copies of it. Is this fastest way you know of?
    import java.io.*;
    import java.nio.channels.*;
    public static void applyFiles( File origFile, File[] files )
      FileInputStream f1 = new FileInputStream( origFile.getAbsolutePath() );
      FileChannel source = f1.getChannel();
      FileOutputStream f2[] = new FileOutputStream[ files.length ];
      FileChannel target;
      for( int x=0; x < files.length; x++ )
        if( origFile.getAbsolutePath() != files[x].getAbsolutePath() )
          f2[x] = new FileOutputStream( files[x].getAbsolutePath() );
          target = f2[x].getChannel();
          source.transferTo(0, source.size(), target);
    }

    2 questions from your code...
    1) I assume the last line should read
    out.write(buffer,0,numRead);
    2) Doesnt this just read in a piece at a time and write that piece to each file? Isn't that degrading performance to have so many files open and waiting at once? Would it make more sense to read into a StringBuffer, then write all the data to each file at a time?
    Thanks
    I'd have to say that your question is loaded. :)
    Without knowing anything about your target system, I'd
    have to say no, this is not the fastest way to copy a
    file to many files. This will end up reading the file
    once for every time you want to copy it. Which may
    work fine if the file is small, but not when the file
    that is being copied is larger then free ram. Or if
    the file channel implementation sucks.
    For the general case, where you don't know how big the
    file will be beforehand I'd say that this is a better
    algorithim.
    public static void oneToManyCopy( File source, File[]
    dest ) throws Exception(s) {
    FileInputStream in = new FileInputStream( source );
    FileOutputStream out[] = new
    w FileOutputStream[dest.length];
    for ( int i = 0 ; i < dest.length;++i)
    out[i] = new FileOutputStream(dest);
    byte buffer[] = new byte[1024]; // or whatever size
    e you like
    int numRead;
    while ( ( numRead = in.read(buffer,0,buffer.length)
    ) ) > -1 ) {
    for ( int i = 0 ; i < out.length; ++i )
    out.write(buffer,0,numRead);

  • What is the fastest way to create thumbnails in CS6?

    Hi All...
    I wanted to know if there is a certain way you can take larger images and have them shrink down to a thumbnail size in an automated fashion?  Instead of having to load each image and change the dimensions and export the image as a thumbnail?  I'm using Web Premium CS6 and also have Lightroom 4.  There must be a less tedious method to create a small size and a large size image...
    Any thoughts?

    You can do this easily using Actions and Batching in Photoshop CS6.
    Here are two video tutorials on how to do this in CS6, specifically for creating thumbnails; using actions and batching actions. The guys is a little long-winded but is very comprehensive.
    And here's an article on how to do the same thing. It's from 2007 but explains the process nicely.

  • Is this the fastest way to insert 100k rows into a database?

    I'm looking to insert ~100k rows into a database as fast as possible. I'm connected to the database through a small LAN with static IP adresses. The target database is running my SQL. Here's the fastest I've gotten the code so far. Task manager shows that it's only sending like 2.5mbps. If I take the size of the 2D array (64MB) and divide by the time it takes to transfer it currently, I calculate ~160kbps. Is that the best I can hope for with the NI DB Toolkit?
    CLD (2014)

    Hi,
    Use DB Tool Insert Data VI to insert the data in the database.
    You can insert complete row data at a time. No need to insert single-single element in database this will reduce your code performance.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!

  • What's the fastest way to create a clipping path?

    In CS3 & 4 I've created a bazillion clipping paths via pen tool and mouse. I've also tried using the various selection tools to create selections, then turning those selections into paths and modifying the path. I've roughed in paths then zoomed way up to fine tune them.
    Is there any plug-in or other slick method to create clipping paths real quickly? Maybe a Wacom pen would work quicker than a mouse? I haven't tried that. I've tried everything else I can think of.
    I happened to notice there are online services that charge like $2.00 to create a clipping path for you. So that either has to be from slave labor or someone has figured out a real fast way to do it.
    I'm sorry to repeat a question if it's been answered before.  I searched for clipping paths in the Photoshop forum and Adobe returned 0 results.

    A Wacom tablet is a must. If you are doing lots of clipping paths, avoid carpel-tunnel, and get the work done easier and faster using the Wacom. I've tried all the sizes and I use a 4x5 because it's all the real estate you need, even on 30" monitors. Other than that, there is no software that thinks like a human can in making discretionary choices. Just get the Wacom and roll. You'll have that pen tool motating at full throttle and even make the labor enjoyable.
    Be sure to take your customary 20 minute ergonomic breaks to let your eyes focus and +20 feet away.
    Best,
    Ken

  • Is this the recomended way to create a GUI??

    Hi all,
    Is this method of creating a resizable form acceptable?package ddbms.gui;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JButton;
    import javax.swing.JTextField;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTable;
    import javax.swing.ButtonGroup;
    import javax.swing.JRadioButton;
    import javax.swing.border.EtchedBorder;
    import javax.swing.border.TitledBorder;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Color;
    import ddbms.gui.MenuBar;
    public class GUIMainFrame
              extends JFrame {
         public GUIMainFrame() {
              super("Distributed Database Sampler");
              m = new MenuBar(el);
              this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              this.setJMenuBar(m);
              initComponents();
              // this.setContentPane(panel);
              this.pack();
              this.setVisible(true);
         private void sqlTable(){
              dbTable.setBorder(eb);
             dbTable.setModel(new javax.swing.table.DefaultTableModel(
                       new Object[][] { {null, null, null, null}
                       , {null, null, null, null}
                       , {null, null, null, null}
                       , {null, null, null, null}
                       new String[] {
                       "Title 1", "Title 2", "Title 3", "Title 4"
             dbTable.setGridColor(new java.awt.Color(204, 204, 204));
         private void initComponents() {
              buttonGroup = new ButtonGroup();
              jRadioButton1 = new JRadioButton("Site 1");
              jRadioButton2 = new JRadioButton("Site 2");
              jRadioButton3 = new JRadioButton("Site 3");
              jRadioButton4 = new JRadioButton("Site 4");
              radioButtonPanel = new JPanel();
              sqlTextField = new JTextField();
              sqlRunButton = new JButton("Execute SQL");
              textButtonPanel = new JPanel();
              radioLayoutPanel = new JPanel();
              commandBorderPanel = new JPanel();
              commandRootPanel = new JPanel();
              dbTable = new JTable();
              dbTableScrollPane = new JScrollPane();
              dataPanel = new JPanel();
              dataRootPanel = new JPanel();
              debugText = new JTextArea();
              debugText.setBorder(eb);
    //debugScrollPane - holds debugText
              debugScrollPane = new JScrollPane();
              debugScrollPane.setBorder(new TitledBorder(eb, "SQL Monitor",TitledBorder.DEFAULT_JUSTIFICATION,TitledBorder.DEFAULT_POSITION,new Font("Trebuchet MS", 0, 12),new Color(153, 153, 153)));
              debugScrollPane.setViewportView(debugText);
    //Setup JTable for database         
              sqlTable();
    //dbTableScrollPane - holds dbTable
              dbTableScrollPane.setBorder(new javax.swing.border.TitledBorder(eb, "Returned Table",TitledBorder.TRAILING,TitledBorder.DEFAULT_POSITION, new Font("Trebuchet MS", 0, 12), new Color(153, 153, 153)));
              dbTableScrollPane.setViewportView(dbTable);
    //dataPanel - holds debugScrollPane(debugTextArea) & dbTableScrollPane(dbTable)
              dataPanel.setLayout(new java.awt.GridLayout(1, 2, 16, 20));
              dataPanel.add(debugScrollPane);
              dataPanel.add(dbTableScrollPane);
    //dataRootPane - holds dataPanel(debugScrollPane(debugTextArea) & dbTableScrollPane(dbTable))
              dataRootPanel.setLayout(new java.awt.CardLayout(16, 16));
              dataRootPanel.add(dataPanel, "card");
    //Radio Buttons
              buttonGroup.add(jRadioButton1);
              jRadioButton1.addActionListener(el);
              jRadioButton1.setActionCommand("1");
              buttonGroup.add(jRadioButton2);
              jRadioButton2.addActionListener(el);
              jRadioButton2.setActionCommand("2");
              buttonGroup.add(jRadioButton3);
              jRadioButton3.addActionListener(el);
              jRadioButton3.setActionCommand("3");
              buttonGroup.add(jRadioButton4);
              jRadioButton4.addActionListener(el);
              jRadioButton4.setActionCommand("4");
    //Radio Button Panel- holds jradiobuttons
              radioButtonPanel.setLayout(new java.awt.GridLayout(2, 2));
              radioButtonPanel.add(jRadioButton1);
              radioButtonPanel.add(jRadioButton2);
              radioButtonPanel.add(jRadioButton3);
              radioButtonPanel.add(jRadioButton4);
    //radioLayoutPanel - controls horizontal position of radioButtonPanel
              radioLayoutPanel.setLayout(new java.awt.CardLayout(180,0));
              radioLayoutPanel.add(radioButtonPanel, "card");
    //SQLTextField
              sqlTextField.setBorder(eb);
              sqlTextField.setPreferredSize(new Dimension(500, 24));
    //sqlRunButton
              sqlRunButton.addActionListener(el);
              sqlRunButton.setActionCommand("run");
              sqlRunButton.setPreferredSize(new Dimension(120, 25));
    //textButtonPanel - holds sqlTextField and sqlRadioButton
              textButtonPanel.add(sqlTextField);
              textButtonPanel.add(sqlRunButton);
    //commandBorderPanel holds textButtonPanel(sqlTextField, sqlRunButton) and radioLayoutPanel(radioPanelButton(r1,r2,r3,r4))
              commandBorderPanel.setBorder(new TitledBorder(eb, "SQL Test String",TitledBorder.TRAILING,TitledBorder.DEFAULT_POSITION,new Font("Trebuchet MS", 0, 12), new Color(153, 153, 153)));
              commandBorderPanel.setLayout(new java.awt.GridLayout(1,2, 0, 0));
              commandBorderPanel.add(textButtonPanel);
              commandBorderPanel.add(radioLayoutPanel);
    //commandRootPanel holds commandBorderPanel(textButtonPanel(sqlTextField, sqlRunButton) & radioLayoutPanel(radioPanelButton(r1,r2,r3,r4)))
              commandRootPanel.setLayout(new java.awt.CardLayout(15, 0));
              commandRootPanel.add(commandBorderPanel, "card");
              getContentPane().setLayout(new java.awt.BorderLayout());
              getContentPane().add(commandRootPanel, java.awt.BorderLayout.NORTH);
              getContentPane().add(dataRootPanel, java.awt.BorderLayout.CENTER);
         private JPanel dataPanel;
         private JPanel dataRootPanel;
         private JScrollPane dbTableScrollPane;
         private JTable dbTable;
         private JScrollPane debugScrollPane;
         private JTextArea debugText;
         private ButtonGroup buttonGroup;
         private JRadioButton jRadioButton1;
         private JRadioButton jRadioButton2;
         private JRadioButton jRadioButton3;
         private JRadioButton jRadioButton4;
         private JPanel radioButtonPanel;
         private JTextField sqlTextField;
         private JButton sqlRunButton;
         private JPanel textButtonPanel;
         private JPanel radioLayoutPanel;
         private JPanel commandBorderPanel;
         private JPanel commandRootPanel;
         private EtchedBorder eb = new EtchedBorder();
         private MenuBar m;
         private EventListener el = new EventListener();
    }

    You could almost say that if you use any of the
    layout managers it will auto resize the form if the
    frame is resized.If thats the case am i not breaking the rules by adding panels on panels
    to get the frame to keep the same relative look?

  • What's the fastest way to create simple report for the web?

    I have Developer 6i and Oracle 9I installed.
    If i have a report already done, how can I make it available to users, so they can access them thru an IP or a host?
    can I achieve that just with my developer 6i (report builder) and my database (oracle 9i)???
    If so, how?

    1) pls see
    [     Publishing reports to web  - 10G  ]
    see
    [    All Docs for all versions    ]
    for 9i version of same document
    2) Better to have 9i builder - 9i ias combinations
    (not sure whether other combination is supported or not. but understandably it is best to have same combination]
    [    All Docs for all versions    ]
    http://otn.oracle.com/documentation/reports.html
    [     Publishing reports to web  - 10G  ]
    http://download.oracle.com/docs/html/B10314_01/toc.htm (html)
    http://download.oracle.com/docs/pdf/B10314_01.pdf (pdf)
    [   Building reports  - 10G ]
    http://download.oracle.com/docs/pdf/B10602_01.pdf (pdf)
    http://download.oracle.com/docs/html/B10602_01/toc.htm (html)
    [   Forms Reports Integration whitepaper  9i ]
    http://otn.oracle.com/products/forms/pdf/frm9isrw9i.pdf
    ---------------------------------------------------------------------------------

  • Fastest way to create subtitles

    Hi! What is the fastest way to create subtitles. I have a short film with one hundred subtitles. I have a text list with time codes, can I use that somehow? Or do I have to enter every subtile separately? And what are the basic settings?

    A possibility seems to be using Quicktime Pro to add your text to a Quicktime movie. The Apple instructions are in Text Track Tutorial. I never used it in real life,... but I tested it in the past and it seemed to be doing what I expected: to layout text over an existing movie at preassigned timecodes...
    For sure you must first adapt your text and timecodes to the required format, and most of all you must have the "original" timecode in your movie untouched (all timecodes your text is making reference to). But if you edited and exported your movie from FCE you lost the original timecodes... so I'm not sure this may help you.
    The other approach is manual: in FCE add a text clip at the correct timecodes, one at the time...
    Piero

  • Fastest way to create buttons from TOC entries?

    I am trying to make a TOC interactive by applying rollovers and links to each entry. What is the fastest way to create buttons out of each entry? Would the "create outlines" command be appropriate? As it stands now, I am copying an entry, pasting it into a new frame, aligning it over the original entry, then converting to button and applying behaviors. There's got to be a more efficient way to do this!
    Using CS3 Design Standard.
    Thanks for any help you can provide.

    Matt,
    function(){return A.apply(null,[this].concat($A(arguments)))}
    Sorry about the attachment. Not sure what happened
    See
    Announcement: File Attachments temporarily disabled
    above. The "temporarily" was an understatement at the time -- this has been in effect for, what? the past 2 years? Now it's just a poignant Daily Reminder of Jive's many shortcomings.

  • Fastest Way To Create Ultrabeat Instrument From Wav Loop?

    Hello, can anyone share the fastest way to create and instrument from a WAV file?
    I know you can convert a wav to ESX24 instrument but I use Ultrabeat not ESX.
    Im finding my self divinding each shot into region and then exporting that to its own file.
    Is there a faster/simpler way?
    -Thanks

    You're right! It does work, however, if you follow these steps:
    1. Right-click on wave file in Arrange and choose "Slice at Transient Markers" or use the corresponding key command.
    2. Select all the split regions right-click on them and choose: Convert > Convert to new audio file(s)
    3. Again, with all the regions selected choose: Convert to new sampler track.
    4. Now launch Ultrabeat. Click on the Import button anc choose the .exs file you've just created (will be located in your project folder). Then drag the audio files into UB as desired.
    You could skip Part 3 altogether and simply slice at transients, convert to new audio file(s) and then in a new kit of UB drag them into the sample window of OSC for each part...

  • What is the best way to create the layout for a single page website in Adobe Muse?

    I was wondering the best way to create the layout for a single page website in Adobe Muse. Does anyone have any suggestions?

    I know how to create a website but will that help me create a single page website? Below I will leave a demo of what I want. I want it to only have one page but multiple sections. What is the easiest way to create a single page website like the demo below?
    Demo Website

  • Fastest way to create child class from parent?

    As the subject states, what do you folks find is fastest when creating child classes directly from the parent? (esp. when the parent is in a lvlib) I thought I'd post up and ask because the fastest way I've found to get working takes a few steps.
    Any suggestions ae appreciatized!
    -pat

    Thanks for the quick response Ben!
    Yea, I apologize, in your response I realize my OP was more than vague haha (it hapens when you get used to your own way of doing things I guess huh)- I'm trying to create a child from a parent so that it has all of the methods that the parent has.
    In order to do so I currently have to open and close LV a few times during my current process so that vi's in memory dont get mixed up- Currently I save a copy of the parent class in a sub dir of where it is saved, close out of LV, open the new 'copy of parent.lvclass', save as>>rename 'child class.lvclass', close LV, and open up the project to 'add file', then right click>>properties>>inheritance.
    Is this the only way to do this?
    Thanks again!
    -pat
    p.s. I'm tempted to steal your cell phone sig, hope you dont mind haha good stuff!

  • Fastest way to create a track of Whole notes beginning to end

    I am trying to create a tapper track consisting of a series or low G (G2) whole notes.
    What is the fastest way of doing this. (they really should be quantized) And, they should also be on beat-one only, throughout an occasional meter change.
    In logic you could drag blocks. I realize I could simply loop and then convert loop to real midi...
    But.. would this run amuck with meter changes. (Remember I just want notes beginning on beat one, and ONLY beat one.
    -Thanks

    Where you have sig changes, copy the region, and adjust it's length to fit the meter … you only need 1 region, rather than try to anticipate the myriad of time sigs that may crop up.
    I understand exactly what you mean, and it makes a lot of sense. I think it's strictly a question of the pattern of usage. If his style when writing is to frequently throw in some odd time sig that he hasn't used much before and is not likely to use again anytime soon, then what you say seems like the best approach. On the other hand, I'm assuming he's more in a situation where he tends to throw in, say, a measure of 2/4, 3/4 or 5/4 every now and then. And it's just a few sigs like that which he tends to use frequently. Therefore it might be slightly easier to have a few regions like that already prepared, and in a place where I can grab them easily. If I have them marked clearly by name and color, I can feel comfortable that I'm avoiding an error. Whereas if I'm creating them over and over again each time I need one, the snap settings and zoom level are relevant, and it's a little too easy to make a careless mistake, if the phone rings at the wrong time.
    Also, he sometimes wants whole notes, and sometimes quarter notes. And maybe there are some other variations like this. This would also be a reason to have some material prepared that I can use over and over again.
    But of course if one day I decide to emulate Stockhausen and throw in a bar in 142/8 time, it makes sense to create that only when I need it, because if I create that region in advance it probably won't get used much.
    So in practice I could picture him doing it a combination of both ways, because chances are certain sigs are used often and others are used rarely. I think it really depends on the writing style, and the pattern of how the unusual sigs are distributed. And also if he sees an advantage in the marking by color. That could be considered helpful, or it could be considered ugly and distracting.

  • Fastest way to create a group from list of recived emails

    I thought this would be as easy as drag and drop but no such luck.
    Here's the situation.  I had a class of 25 students email me from their mobile phones all using the same subject.  Now I'd like to create a mailing list / group so that I can easly contact all of them if need be.  I tried creating a new group and dragging all of the emails into it to no avail.  I also tried right clicking and checking the menus to see if there were any options which there weren't.
    Anyone have any suggestions?  I'd be open to using automator or something similar if it worked.
    Thanks,
    Greg

    I think the fastest way to do this is in Mail>Message>Add to Address Book, then in AB>File>New Smart Group>Card:>Was updated After... say yesterday, then select all those & make a new (not Smart) Group to drag them to so it won't change after that.
    Unless you could get them all to eMail with some other unique that AB can see as a Group field.

  • What's the fastest way to look up a User's Work Items?

    Hi, my SCSM environment has a few different service desks and plenty of customer drive-by's.  Sometimes when a customer comes up and asks for a status, the SD personnel can't find their ticket quickly. The fastest way right now is to 1.) click on CONFIGUATION
    ITEMS; 2.) Search for the Affected User; 3.) Click on the Affected User; 4.) Click on the Affected User's Related Items; 5.) Search the related items for the proper Work Item; 6.) Load the Work Item.
    It's not bad, but it's a lot of steps and I'm wondering if anybody has a faster method in place.

    Just to poke holes in the salesmanship, Consider that you might have an easier time in doing any of the following:
    Create a view that lists all open incidents, and make the first column Affected User. Analysts can filter or sort by this column to get quick info
    The search box in the top right corner can be set to users, right click the down arrow to see all options. 
    the search box in the top right can be used to search work item IDs or titles.

Maybe you are looking for

  • Problem in converting AppleWorks into RTF

    Hi! I have a bunch of .cwk files (AppleWorks) that I need to convert into RTF format. In the script I use I have a proble with the following code: tell application "AppleWorks" activate open MonFichier save MonFichier in file (dossier & name_Fich & "

  • Appv package on RDS resource utilisation

    are there any resource utilization advantages of using APPV Package on RDS server vs native application installation on RDS. Example: The app that requires 100K of memory. There are 30 simultaneous connection to the app. Would the memory utilization

  • Converting imovie video to mp3

    I want to make uploading a video on youtube more faster and mp4 slows the processing down what can i do?

  • Urgent: Please help. how to solve the time delay during buffer read and write using vc++

    I need to continuously acquire data from daqmx card, write into a file and at the same time corelate (in terms of time) the data with signals from other instruments. The current problem is that there is time delay during read and write data into buff

  • Entity attribute seems to reset on commit

    I'm using JDeveloper 11g 11.1.1.2.0 I have View Object based on two entities. I have a transient attribute on VO which is a copy of the entity based primary key of VO. I have an LOV configured on this transient attibute which I use on my JSPX page. A