How do I specify 16bit R5G6B5 pixels when creating a BufferedImage?

Hello All,
I'm trying to load raster data from an image file and it may contain different bit depths. I'm loading this data into a BufferedImage using the constructor
BufferedImage(ColorModel cm, WritableRaster raster, boolean isRasterPremultiplied, Hashtable<?,?> properties)
I'm trying to figure out how to specify the exact way the pixels are stored, but I'm having a really hard time. It seems that I would want to put this information in the ColorModel, but I can't find anything to specify that. The WritableRaster is another place I looked, but when I create that, it also doesn't ask for (or I don't know how to provide) the specific color info. I have a file that stores it's pixel data in 16 bits, but the colors are separated out by Red (5bits) Green(6bits) Blue(5bits). I have the hex color masks for the color, but I don't know how to use them without first creating a BufferedImage, then using a PixelGrabber or other such process for editing the pixels after the fact. I'd like to be able to specify the the info when I create the image. Can anybody help me?
Thank you!

Quasi_Stomach wrote:
If I use the SinglePixelPackedSampleModel, I'm required to provide a scanlineStride and bandMask array. Do you know what these mean?I think you're referring to this constructor:
public SinglePixelPackedSampleModel(int dataType, int w, int h, int scanlineStride, int[] bitMasks)Ultimately, the data is going to be stored in a one dimensional array, say a short[]. The SampleModel knows how to access the data elements for the pixel in row r column c, for example.
Suppose I have a short[] where each short represents a pixel packed as 565_RGB. Bit masks are needed to extract the red, green and blue components from a short. These masks are:
int[] bitMasks = {0xF800, 0x7E0, 0x1F}; Write those out in binary and you'll see.
Second, an image is two-dimensional but a DataBuffer is one-dimensional -- basically a short[] in our case. How is the image folded in? Row by row. If you ran through the data in the short[] you would see row 0 of the image, then row 1, row 2, etc... But sometimes there's padding in there. It may be advantageous (because of video hardware) for the image width to be a power of 2: 2, 4, 8, 16, 32... and if the width isn't there may be padding (zeroes) in the short[] that guarantee that each row's data starts at an offset that is a multiple of a power of two. For example, you may have an image with width 200 that's padded out to 256, and the rows start at offsets [0], [256], [512], ...
This larger width, 256, is the scanlineStride. Chances are, if you don't know about a specific scanlineStride, it's going to be the same as the width.
Edit: All this being said, I can't remember the last time I needed to directly create or manipulate a SampleModel. Are you sure you need to go this low level? Perhaps you need to step back and describe the big picture. There may be another approach that's much easier to do what ever it is you are trying to do.

Similar Messages

  • How do you shuffle the image order when creating a new slideshow in apterture 3?  i would like to do this automatically when creating a new slideshow.  i see how you do it when you just play a slideshow.

    how do you shuffle the image order when creating a new slideshow in apterture 3?  i would like to do this automatically when creating a new slideshow.  i see how you do it with presets when you just play a slideshow, but i don't see an option to randomly shuffle the slide order when you create a new slideshow.  i know you can sort it by different fields, but i want it to be random.  thanks.

    If you want to rearrange images in random order you can try an AppleScript:
    retrieve a list of selected images from Aperture
    shuffe the list properly
    create an album in Aperture and add the images from the list to the album (make sure that the album set to be orederd manually)
    Here  is a sample script that shuffles the selected images and displays them in random order in Full Screen Mode:
    on removeItem(ims, i)
      -- remove the item at position "i" from a list ims
              if ims is {} then return {}
              if (length of ims is 1) then return {}
              if i < 2 then return rest of ims
              if (i = length of ims) then return (items 1 thru (i - 1) of ims)
              if i > (length of ims) then return ims -- should be error?
              return (items 1 thru (i - 1) of ims) & (items (i + 1) thru (length of ims) of ims)
    end removeItem
    on shuffle_items(ims)
      -- shuffle the items of the list "ims" randomly
              local numitems, ims_shuffled, nextrest, nextpick, i
              set numitems to length of ims
              if length of ims < 2 then return ims
              set ims_shuffled to {}
              set nextrest to ims
              repeat until nextrest is {}
                        set i to (random number (numitems - 1)) + 1
                        set nextpick to item i of nextrest
                        set beginning of ims_shuffled to nextpick
                        set numitems to numitems - 1
                        set nextrest to removeItem(nextrest, i)
              end repeat
              return ims_shuffled
    end shuffle_items
    on shuffleIms()
      -- retrieve the selected images from Aperture
      -- and display them in random order in full screen mode
              local imageSel, shuffled, i
              tell application "Aperture"
      activate
                        set imageSel to (get selection)
                        set shuffled to my shuffle_items(imageSel)
                        set fullscreen to true
                        if imageSel is {} then error "Please select some images."
                        repeat with i from 1 to count of shuffled
                                  reveal {item i of shuffled}
      delay 3 -- chnage that to the time you want
                        end repeat
                        set fullscreen to false
                        return shuffled
              end tell
    end shuffleIms
    shuffleIms()
    Some more code snippets to go from here:
    To create an album:
                        tell library 1
                                  if not (exists album "shuffledAlbum") then
      make new album with properties {name:"shuffledAlbum", image version:shuffled}
                                  end if
                        end tell
    And to add the images from the shuffled list to the album:
                        repeat with i from 1 to count of shuffled
                                  duplicate item i of shuffled to album "shuffledAlbum"
                        end repeat
    Regards
    Léonie

  • How enter the values in to table when create entries option is not working

    hi everyone,
         can u please tell me How enter the values in to table when create entries option is not working.
    it's urgent.
    thanking u all

    Hi Shree,
    how many entries u want to insert ,,
    is it a ztable or custom table ..
    just tell me ur clear requirement ..
    clarify the same ..
    if no options avaliable then if its less entries or some value u can do it through debugging ..
    if its bulk entries then u can write a program ..
    just let me know ..
    regards,
    VIjay

  • How to avoid shut down BPELPM Server when creating a user?

    Hi,
    How to avoid shut down BPELPM Server when creating a JAZN user and after doing changes to user-properties.xml?
    Thanks,
    Jorge

    this configuration is only supported on a midtier - there is a work around for a standalone install, nevertheless I would not recommend this for production ..
    if this is NOT a production enviroment - I can try to get you the information .
    /clemens

  • How do I specify an output folder when exporting?

    I am running Adobie Premiere Pro CS5.5.
    I got to File -> Export -> Media. The "export settings" box appears.
    I know how to set the settings for my desired export. The issue I'm having is under "summary" where the output is specified. Often, I find my video is being outputted to random and unwanted folders. My videos have ended up in folders buried deep in my hard drive where a few have been lost forever. How do I specify the output location so I can easily find my video in a place that I want and is convenient?
    -- extremely frustrated.

  • How to set plant to all WBS when creating Project using Copy Standard Project  (CJ20N)

    Hello
    I have created standard project with several WBS. Now I want t o create operative project in CJ20N by copying standard project. While copying I want that the system allows me to define the plant for which the project is created and it gets automatically copied to project defination and all WBS elements. Since I have around 30 plants, I havent maintained any default plant in Standard project. How I can achive this requirement to specify the plant when creating project so that it is automatically copied to all WBS.
    Murad

    Hi Murad,
    I can see three viable options over here. If you are using the same plant across the project structure (on all the WBS elements) you can then go with the suggestion Saurabh suggested (Defaulting it in the project profile itself).  In addition to writing a substitution rule at the PD level, you can also go ahead with the option of mass change in case you have created a project(by copying from an operative project already with some default plant.)? Is something stopping you from carrying out mass change? Please let me know.
    Thanks
    Varun

  • How do I select and format fonts when creating a web Journal in Aperture?

    I am creating a web journal in Aperture 3.5.1.  There is a not very functional way to create text boxes and add text interspersed with images.
    I can open the font window, but highlighting text and formatting it in the font window has no effect.
    In addition, the size of the font actually changes from paragraph to paragraph for no apparent reason.
    How do I format text when creating a web journal?
    After I have created the web site, I can open the html file and edit the source code, but this is very tedious.
    --Kenoli

    Hi
    Do You mean by "front" and "back" mean beginning of movie versa the end of it
    or Picture in picture effect - zooming into one photo then to another ?
    There is a picture in picture function in iMovie'09 - but very basic and
    to move around in a photo You got the "Ken-Burns effect".
    Still to do this with 100% control there are only two good alternatives
    • QuickTime Pro ($30 QT-Pro update) - Hard to use very demanding
    • FinalCut Express ($199) - Hard to get up and running
    (Steap learning curve to start with) - Then Pic in pic is dead easy.
    Yours Bengt W

  • How to avoid duplicated customer ref. no when create new sales order?

    Hi,
    In my company, we need input customer ref. no when create a new sales order, but I found there was no any validation to avoid input a existed number.
    Can somebody show me how to add some check function on this filed?
    thanks.

    Hi,
    This can be handled in standard system.
    Go to Administration> System Initialization> Document Settings>Per Document (Tab)> Select Sales Order-->Tick Block release (When duplicated  customer reference no. occurs).
    Thanks,
    Joseph

  • How to save LIST_LINE_ID of Price List when create Sales Order Line

    I dont know how save the LIST_LINE_ID of the Price List on Sales Order or anywhere when create Sales Order Line.
    I create with the following steps:
    Step 1: Create Price List for Item A with two line: Line 1 (Unit Price = 10,5, Pricing Attribute with Tax Classification Code = 5%), Line 2 (Unit Price = 11, Pricing Attribute with Tax Classification Code = 10%)
    Step 2: I create Sales Order Line with Item A, Tax Classification Code = 5% --> Unit Selling Price = List Price = 10,5 but dont bookorder
    Step 3: I update the Unit Price of Line 1 into 11.55.
    Step4 : I book this Sales Order. Howerver, I use form personalization to customize Book Event: if the Unit Price of Item on Price List > Unit Selling Price then cant not Book. But I dont konw List Price of Sales Order belong the line of Price List.
    Please help me check this issue. Thanks for your supports.
    BinhTC
    Email: [email protected]

    Bob's right - except that if you have OM: List Price Override Privilege set to 'Unlimited' (and from your scenario it sounds as if you have) it is possible that the value in unit_list_price will vary from what was originally retrieved from the price list.
    In that case, a safer bet is to use :LINE.original_list_price in your personalization as this will always contain what was originally retrieved and will mean you can avoid any repeat lookup via list_line_id.
    Regards,
    Jon

  • How can I reserve resources or rooms when creating an event in the Calendar (Exchange)?

    On our Exchange server we have configured a number of conference rooms and other resources that users can book/reserve through Outlook when creating events.  When I create an event in the iPhone on my Exchange calendar, if I add a location the option does not exist to book rooms/resources (even if I add in the resource word-for-word as it exists on Exchange server). I am also unable to book it if I invite the "Contact," if I may call it that, from our Global Address List.   Does this capability exist in the iPhone?

    I can't seem to do this successfully. I use the GAL to select the room, but when I send out the meeting I immediately get an automated response back that the delivery failed. I heard this may be because the iPhone OS does not distinguish between a normal attendee and a resource. Yet you seem to have it working. What version of Exchange are you using. Is it on Mac or PC?  We are about to upgrade from Exchange 2003 to 2010, maybe that will help solve this?
    Also, (this may just be semantics) on the iPhone under "Mail, Contacts, Calendars" the Exchange configuration is set to "on" to sync calendars. Is this the same as having the Exchange calendar "set as the default calendar" mentioned above?

  • HOW CAN I GET A DIFFERENT STATE WHEN CREATE THE VM

    All i Always get is 
    Country
    United States  (US) 
    Region Washington (WA)
    City Redmond
    ZIP code
    98052
    What do i do to change the state ...Please help

    Hi,
    Would you be able to provide us details as to when you get State option while creating a VM?
    Is the address you have mentioned your billing address? Does this come up in the Management portal or the Billing portal?
    You could refer the following link to create a Windows VM in Azure:
    http://azure.microsoft.com/en-us/documentation/articles/virtual-machines-create-custom/
    If you notice in the article, when creating a VM in the Management Portal, it only prompts you for the region, affinity group or Virtual Network, as shown below.
    Regards,
    Malar.

  • How to use va51 and vb01 together when create sales order by VA01

    We have discovered that it is possible to enter a material in VD51 (item proposal) that is not listed to a customer(Defined in VB01). When creating a sales order, it is possible to enter a quantity and save the order. This should not be possible.

    We have discovered that it is possible to enter a material in VD51 (item proposal) that is not listed to a customer(Defined in VB01). When creating a sales order, it is possible to enter a quantity and save the order. This should not be possible.

  • How do I specify the build number when deploying an iOS application (not version number)

    I'm looking for a way to specify the application's build number when deploying an iOS application.
    Currently in the -app.xml file, you can specify a version number by using:
    <versionNumber>1.0.24</versionNumber>
    But when submitting to the iTunes Connect store, I want to be able to submit the new updates as a build change, and not version change to avoid the approval process again.
    Can this be done ?
    Thanks in advance.
    -Daniel

    Hi Gig52,
    Unfortunately, there is no way for you update/modify/increment the build/version number information from the command line. You will have to set that via the Project Explorer. You could check the box labeled Auto Increment in the Version Information property to have the version number automatically increment each time you build your application.

  • How do I specify the file extensions when opening a file in Labview?

    When opening a file, the file open dialogue box appears with a drop down box called 'Files of type *.*
    I want to only display files of type IPC, and I will create all my files to have this extension.
    I have been using this technique in VB for some time, but I cannot find a method of doing this in Labview so far, can anyone help?

    Use the function "File Dialog" and wire your type to "pattern label".
    Hope this helps.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...

  • How to make cost element field appear when create network activity service

    Hi All,
    Please help. We create a project ,wbs and network activity using external service. How can we make appear the cost element when the service master appear. The system require cost element but we cannot see the cost element field.
    Steps :
    *. CJ20n.
    *. Create WBS and network header
    *. Then network activity for external service.
    *. Then it appears service specifications : ext specs Task List Maintain
    *. I Put Service no, and the error message appears :
    Please enter a cost element
    Message no. SE121
    *. But we can find where the cost element is. It seems the field disappear.
    PLease help.
    Thank you.
    Nies

    Hi,
    Yes. It is already blank. But the cost element field still not appears when we create activity service. It shows :
    Please specify a valid account assignment
    Message no. SE181
    Diagnosis
    You have entered an account assignment category in the document item for which an account assignment is mandatory.
    All account assignment lines in the service specifications either have been deleted or are inactive (e.g. account assignment lines of a contingency item).
    Procedure
    Please enter an account assignment for the services or value limits.
    The entry of an account assignment is unnecessary if you choose "unknown account assignment" in the document item.

Maybe you are looking for

  • Automatic Payment Program(F111) not picking Bank Sub accounts

    Dear all, The entiries genertaed from automatic payment program(F111) is not picking the bank sub accounts (Receipts/Payment GLs) which are given in the following node:- Financial Accounting --> Bank Accounting --> Business Transactions -->Payment Tr

  • How To Set the Resultstate of Business Logic CO for Loop Decision Action

    Hi, I'm using a pre-conditional loop block in my GP process and using a Business Logic CO for the loop decision action. My expectation is the business logic CO should be executed at background and based on its resultstate the loop flow will happen. I

  • Trouble exporting to camera! Need help please

    Hi all, Hope u can help. Only recently has imovies not allowed me to export movies to my camera. The message appears:- "imovie lost connection to the video camera. Please check and try again." I have checked firewire which is installed correctly- i k

  • Getting 5002 error

    Getting 5002 error, seems like others are not able to download or update either.

  • Bookmarks not showing when bookmark icon tapped

    Hi, I have created an ePub and am seeing a problem with it when trying to add a bookmark. Sometimes tapping the bookmark icon in the top right of the book will result in the red bookmark ribbon appearing, but then on other occasions, however much I t