How to use an alpha channel or transparency?

I'm trying to make a game and I want to have a background and on top of that sprites. But the sprites need to be transparant in some parts. I have tried with gif's and png's but nothing works. Can anybody help me?
this is my code, I don't use paint because I render actively in fullscreen exclusive mode
private void initResources() {
Image img;
gc = getGraphicsConfiguration();
try {
img = ImageIO.read( new File("c:\\test.png") );
sprite = gc.createCompatibleImage(100, 100, Transparency.TRANSLUCENT);
if ( img != null && sprite != null )
((Graphics2D)sprite.getGraphics()).drawImage( img, null, null );
catch ( IOException ioe ) {
System.err.println(ioe.toString());
private void renderFrame(Graphics2D g2) {
g2.setPaint( Color.BLACK );
g2.fillRect(0,0,800,600);
g2.drawImage( sprite, 0, 0, null );
g2.dispose();
}

Hm, seems like I found a partial solution myself using an AlphaComposite. Problem now is that it only works with gif's and not with a png.
private void renderFrame(Graphics2D g2) {
g2.setPaint( Color.BLACK );
g2.fillRect(0,0,800,600);
g2.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER ) );
g2.drawImage( sprite, 0, 0, null );
g2.dispose();

Similar Messages

  • How to use the alpha channel

    I am using the video editing software "Magix Video deluxe 2008 Pro". Is it correct that after buying Quicktime Pro I can use all features from the Pro version via the export window of my video editing software (which is already offering me Quicktime export with the free QT-version)?
    I have a movie made with greenscreen and in my video editing software I have already seperated the person in front from the greenscreen. Now, how do I tell Quicktime, which parts should be transparent, so that Quicktime "knows" what information to write in the alpha channel?
    Thanks a lot!
    Nils

    I don't know about the software you used. If it made the "alpha" channel then you can enable it in QuickTime Pro by following these steps:
    Open the file and then open the Movie Properties window.
    Highlight the "Video" track and click the Visual Settings tab.
    In the lower left corner is a pull down menu for "Transparency". Set it to Straight Alpha and use Save As to make a new file leaving your original untouched for further editing.

  • Import image as a mask or How to use an alpha mask for transparency mask

    Hello,
    Basically I need to know how to import 1 image into another image as a mask.
    What I'm trying to do:
    I have a bunch of large images that put together make 1 very large image (ortho land images). I also have corresponding images, lets refer to them as mask images, that would mask out parts of the large ortho image I want to import it too. These mask images basically look like a PS mask. They are feathered black to white images. I need to be able to import them as a mask.
    Is there away, if so how?
    Thanks!!!!

    If the masked out areas of your image are to be black, see if this approach fits your needs and forget about creating a mask. Instead bring your "mask image" into your ortho land image using your favorite technique. Now change the blend mode of this mask image to mutiply. You should now see land wherever your mask is white, black where the mask is black and transition regions where the mask has a gray value.
    Alternatively, you can make an alpha channel if you want by turning off all layers except your "mask image", switching to the channel palette, Ctrl clicking on the rgb channel (to create a selection) and then clicking on the Save Selection as Channel icon at the bottom of the palette. You can then create a luminance mask by going back to the layer palette, selecting the layer you want to mask and click the Add LAyer Mask icon at the bottom of the palette.
    Paulo

  • How to use multiple alpha channels

    Hi there. I'm using Cinema4D for some 3D animation. I'm using an object buffer compositing tag to isolate certain elements in my scene. (C4D can create an alpha channel for each object). This is then rendered out as a multi-layered PSD sequence. However C4D puts the extra channel info (z-depth, object ID, etc) into alpha channels. But AFAIK, AE only reads the first alpha channel.
    Is there a way to read extra alpha channels?

    This topic came up about two years ago, you might try searching the forum.
    IIRC, the conversation was enlightening for several of us old timers who had never even heard of multiple alphas.
    Closest I've ever gotten was using the four separate color channels to hold unrelated grayscale movies. Each was used to drive a different 3d parameter of Card Dance.
    bogiesan

  • How can I dispaly alpha Channels to proxy and show transparency correctly?

    Hi all! I have a problem. Please help me. Thank you very much.
    I want to display alpha Channels to proxy and show transparency correctly. I have get the datas of alpha Channels and RGB color. Following are the codes:
    void HiddenData::PaintPreview()
    if( !channelData ) return;
    PSPixelMap pixels;
    int spotChannelCount = gFilterRecord->documentInfo->alphaChannelCount;
    pixels.version       = ( spotChannelCount > 0 ) ? 2 : 1;
    pixels.bounds.left   = proxyRect.left;
    pixels.bounds.right  = proxyRect.right;
    pixels.bounds.top    = proxyRect.top;
    pixels.bounds.bottom = proxyRect.bottom;
    int32 proxyWidth  = proxyRect.right - proxyRect.left;
    int32 proxyHeight = proxyRect.bottom - proxyRect.top;
    pixels.imageMode     = gFilterRecord->documentInfo->imageMode;
    pixels.rowBytes      = proxyWidth * gFilterRecord->documentInfo->depth / 8;
    pixels.colBytes   = 1;
    pixels.planeBytes    = proxyWidth * proxyHeight;
    pixels.baseAddr   = channelData;
    // new for version 2 of PSPixelMap
    PSPixelOverlay* overlay = NULL;
    if( spotChannelCount > 0 ){
      overlay = new PSPixelOverlay[ spotChannelCount ];
      if( overlay ){
       int j = 0;
       for( int i = 0; i < spotChannelCount; i++ ){
        overlay[i].data = channelData + pixels.planeBytes * (4 + i);
        overlay[i].rowBytes = pixels.rowBytes;
        overlay[i].colBytes = 1;
        overlay[i].r = (unsigned8)spotColorList[j++];
        overlay[i].g = (unsigned8)spotColorList[j++];
        overlay[i].b = (unsigned8)spotColorList[j++];
        overlay[i].opacity = 50 * 2.55;
        overlay[i].overlayAlgorithm = kStandardAlphaOverlay;
        overlay[i].next = ( i == (spotChannelCount - 1)) ? NULL : overlay + i + 1;
       pixels.pixelOverlays = overlay;
       pixels.colorManagementOptions = kViewAsStandardRGB/*kViewAsMask*/;
    pixels.mat = NULL;
    pixels.masks = NULL;
    pixels.maskPhaseRow = 0;
    pixels.maskPhaseCol = 0;
    (gFilterRecord->displayPixels)(&pixels, &pixels.bounds, 0, 0, (void *)hdc);
    delete[] overlay;
    But there is a problem.The image of alpha Channels in proxy is not clear, because overlay[i].opacity = 50 * 2.55.
    It looks like  diffrent from displaying in photoshop.I do not know how to use pixels.mat and pixels.masks.
    Thanks!

    I run the plugin. But It can not show alpha channels. Can you show the code in your example clearly.Thanks! Following are the frames.
    The original document:                                 
    The result:
    Can not show the alpha channels.

  • How to import an alpha channel from .PSD file?

    I have a photoshop file (.psd) with an alpha channel. When I import this file into AE, I do not see the alpha being available or perhaps I don't know how to find it. I've followed this instruction but nothing happens afterwards. Okay, so my question is, when I drop the .psd file into my comp, how or where do I enble the alpha channel?

    I am not sure this a bug.
    It could be. But note that I can produce an identical case in which this behavior is not a bug.
    The thing is, in the world of video applications, Alpha Channel means "fourth channel used to store transparency values".
    In Photoshop, it normally means the same thing, but it can also mean "arbitrary channel created and stored for whichever reason the user may want it on the future". Typically, to save a selection so that it can be retrieved later. In fact, you can have many of these arbitrary channels.
    So, imagine this scenario:
    1. User makes a selection of the outline of the house.
    2. Instead of cutting the pixels outside the house, or creating a layer mask, the user goes to the Channels panel and hits the "Save selection as channel" button (or equivalent menu command).
    Photoshop creates a fourth channel (or even a fifth or a sixth if there were additional channels already), which is called "Alpha" but the user never did anything to make the information in that channel produce transparency.
    If after making the selection, the user would have cutted pixels or created a layer mask, then that operation would be relfected on what we normally consider as Alpha channel.
    In this case, what you can do is go to channels pannel, control click the thumbnail so that the channel is loaded as selection, then create a layer mask (Layer > Layer Mask > Current selection) from that selection. That's it.

  • What codec to convert .MXF and MP4 files into to use with alpha channels in Ae and Pr CS6?

    When I import .mxf File, shot on a Canon C300, into after effects, the alpha channel options are greyed out, when I look in, interpret footage, main. This also is the case importing .MP4 files, shot on a Gopro hero 3. I used to use final cut and using compressor convert the files to pro res 4444 or 422. What's my new workflow for preparing files with alpha channels to use in After Effect and Premiere and do I use Media Encoder to do it?

    When I import .mxf File, shot on a Canon C300, into after effects, the alpha channel options are greyed out, when I look in, interpret footage, main. This also is the case importing .MP4 files, shot on a Gopro hero 3.
    Better question: Where do you expect that Alpha channel to come from and contain any useful info for transparency? You're making a fuss over a non-issue. Unless you apply keying or other methods of creating transparency, even if there were an Alpha channel it would be fully opaque and then what's the point?
    Mylenium

  • How to render with alpha channel?

    Hello,
    I am trying to render a comp with alpha  channel QT PNG. When i play the clip it's with black BG but if i  imported in AE is with alpha channel. How to render in such way that i  can play in Quicktime without the black BG? Am i missing something?
     Thanks!

    robert_ro wrote:
    Hello,
    I am trying to render a comp with alpha  channel QT PNG. When i play the clip it's with black BG but if i  imported in AE is with alpha channel. How to render in such way that i  can play in Quicktime without the black BG? Am i missing something?
     Thanks!
    You've successfully rendered the alpha channel. Alpha information is not displayed as expected in some players. IN QT Player, your alpha is transparent but the player has no background so it defaults to black. Check the playback operations and settings/prefs for QT Player, there may be a way to tell it to show alpha information.
    bogiesan

  • How do I delete alpha channels in Photoshop Elements?

    I need to delete Alpha Channels in Photoshop Elements 12 for photos that are going to be used in publication.  How do I do it.?

    Go to Select>Delete Selection

  • BitmapData masking: how to merge 2 alpha channels?

    How can I apply an alpha mask from one bitmapdata to another? In other words, I want to merge the alphas, not simply copy one alpha channel to another bitmap.
    Here's an illustration:
    Notice that both the triangle and the ellipse have alpha channels, and the result is an intersection of these alpha channels. The RGB channels from the second image are used, and discarded from the first.
    I've looked into using BitmapData/merge(), draw(), copyChannel(), but they don't seem to do what I want. Anyone?
    Cheers.
    -Aaron

    Aha, looks like the answer was right under my nose: copyPixels() can do exactly this:
    If you include the alphaBitmap and alphaPoint parameters, you can use a secondary image as an alpha source for the source image. If the source image has alpha data, both sets of alpha data are used to composite pixels from the source image to the destination image. ThealphaPoint parameter is the point in the alpha image that corresponds to the upper-left corner of the source rectangle. Any pixels outside the intersection of the source image and alpha image are not copied to the destination image.
    Cheers.
    -Aaron

  • How to use  the same channel to send a file and messages to the server

    I'm trying to develop a simple program that will send and receive files from the server and in the same time I need to communicate with the server through the messages
    I'm using TCP Socket
    my problem is
    I have only one channel
    so, I have no option, either I can use it for sending the file itself or sending the message .. but not both !
    my question is : How can I use the same channel for sending and receiving (file & message)
    I would appreciate for any clue or hint
    best

    kajbj wrote:
    kmarwani wrote:
    Thanks for reply
    yes, that what I'm thinking to do
    but, in case of sending binary file, if I attached a flag on its header, will it corrupt the file ?
    bestThe other end would of course need to decode the messages that you get, and only write the "data" part to the file.Thanks
    I'm gonna try to hard-code what you suggest and i will post what happen with me here
    even though I'm not sure how can I add header to a binary file and remove it from the file at other end. (coz I read it as stream and send as array without touching its contents)
    this how I'm sending the file
    ConnSocket = CSocket.accept();
    ToClient = new DataOutputStream(ConnSocket.getOutputStream());
    File myFile = new File("abc.jpg");
    FileInputStream myFileInStream = new FileInputStream(myFile);
    BufferedInputStream mybuffInStream = new BufferedInputStream(myFileInStream);
    myBytArray = new byte[(int) myFile.length()];
    mybuffInStream.read(myBytArray, 0, myBytArray.length);
    ToClient.write(myBytArray, 0, myBytArray.length);
    ToClient.flush();
    myFileInStream.close();best

  • Save for web and using a alpha channel to optimise a jpg? Is it missing in CS4/5+ ?

    Hi guys,
    I have just tried to do an old technique I used to use to reduce the szie of big background images, and they was to make a alpha channel and specify which areas of the image you want to be kept at the highest quality and what areas you wanted it to be low quality.
    I dont seem to be able to find it anywhere in the "Save for web" screen.
    This post here suggests it might have been dumped after CS3???
    http://forums.adobe.com/thread/370291
    Any help would be great

    As far as i know those features were removed from Save for Web after cs3.
    MTSTUNER

  • .png animation files... how to import keeping alpha channel please!

    My graphics man has buit me a animation on white swirly things on his system
    and given me them as sequential files.
    On gfx without alpha I open then in quicktime, open a sequential files then export to dv.
    Now of course dv will not keep alpha channels so any help on how to take this animation alpha .png and get it into my fcp time line would be much appreciated,
    regards
    daz

    Apple Animation is a high quality video codec that can support an alpha channel.
    While there are other formats that also support alpha channel, Apple Animation is the codec of choice on the Mac because it lets us transfer files between different software packages without any hassle.
    For instance, you could export a 3D scene from Maya, manipulate it further in After Effects then drop it into the FCP Timeline, all without converting it to something else at each stage.

  • How to using Virtual fibre channel feature in IC 3.5?

    Hi ,guys ,i have noticed that microsoft released IC 3.5 to support virtual fibre channel in redhat and centos linux.
    the links are:
    http://technet.microsoft.com/en-us/library/dn531026.aspx
    http://blogs.technet.com/b/virtualization/archive/2014/01/02/linux-integration-services-3-5-announcement.aspx
    in these links above ,notes 2 says:
    While using virtual fibre channel devices, ensure that logical unit number 0 (LUN 0) has been populated. If LUN 0 has not been populated, a Linux virtual machine might not be able to mount fibre channel devices natively.
    but I do not understand how to ensure logical unit number 0 has been populated ,anyone who have tested such new features please share your expirence , thank you very much.
    yoke88
    IM:[email protected]

    The same issues as yours,no HBA card can be seen
    I have tried the command here to list hyper-v virutal fiber channel card in oracle linux 6.5 ,but no luck,and EMC powerpath does not support UEK r3 which was installed default on OL 6.5 X64,I will try Oracle linux 6.3 with IC 3.5
    http://mikent.wordpress.com/2012/02/07/how-to-find-wwn-of-hba-on-redhat-6-x/
    [root@computer01 ~]# uname -a
    Linux computer01.localdomain 3.8.13-26.1.1.el6uek.x86_64 #2 SMP Thu Feb 13 19:42:43 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
    [root@computer01 ~]# lspci -nn
    00:00.0 Host bridge [0600]: Intel Corporation 440BX/ZX/DX - 82443BX/ZX/DX Host bridge (AGP disabled) [8086:7192] (rev 03)
    00:07.0 ISA bridge [0601]: Intel Corporation 82371AB/EB/MB PIIX4 ISA [8086:7110] (rev 01)
    00:07.1 IDE interface [0101]: Intel Corporation 82371AB/EB/MB PIIX4 IDE [8086:7111] (rev 01)
    00:07.3 Bridge [0680]: Intel Corporation 82371AB/EB/MB PIIX4 ACPI [8086:7113] (rev 02)
    00:08.0 VGA compatible controller [0300]: Microsoft Corporation Hyper-V virtual VGA [1414:5353]
    [root@computer01 ~]# fdisk -l
    Disk /dev/sda: 53.7 GB, 53687091200 bytes
    255 heads, 63 sectors/track, 6527 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x000896c0
       Device Boot      Start         End      Blocks   Id  System
    /dev/sda1   *           1          64      512000   83  Linux
    Partition 1 does not end on cylinder boundary.
    /dev/sda2              64        6528    51915776   8e  Linux LVM
    Disk /dev/mapper/vg_computer01-lv_root: 49.0 GB, 48964304896 bytes
    255 heads, 63 sectors/track, 5952 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    Disk /dev/mapper/vg_computer01-lv_swap: 4194 MB, 4194304000 bytes
    255 heads, 63 sectors/track, 509 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000
    [root@computer01 ~]# lsmod |grep hv
    hv_netvsc              21641  0
    hv_utils                7440  0
    hv_balloon              9843  0
    hv_storvsc             10236  2
    hv_vmbus               92011  5 hid_hyperv,hv_netvsc,hv_utils,hv_balloon,hv_storvsc
    [root@computer01 ~]# modinfo hv_vmbus
    filename:       /lib/modules/3.8.13-26.1.1.el6uek.x86_64/kernel/drivers/hv/hv_vmbus.ko
    version:        3.1
    license:        GPL
    srcversion:     8BAC864516830DFFF7DC2B1
    alias:          acpi*:VMBus:*
    alias:          acpi*:VMBUS:*
    depends:
    intree:         Y
    vermagic:       3.8.13-26.1.1.el6uek.x86_64 SMP mod_unload modversions
    using microsoft virutal fibre chanel trouble shooting guide ,i see the event logs indicate the VHBA card was successfully added to the vm.
    yoke88
    IM:[email protected]

  • How to use Jco to read a transparent table?

    For example I want to use java to read table T002,
    I can use Jco, but does anybody know how to use Jco to read a data table?
    Best regards,
    Lament

    Hi,
    if its exposed Using RFC you can use JCo. Other wise you could give a try accessing it using JDBC.
    Regards
    Ayyapparaj

Maybe you are looking for

  • How to dictate, type or edit docs on MacBookAir for use in Word?

    Hello, I have a MacBookAir.  Mr computer at work uses Windows 7 and Word.  I'd like to be able to use my MacBookAir to create and edit documents for work purposes.  I'd also like to be able to use a dictate-to-type programme such as Dragon on my MacB

  • Content Server - Print Attached PDF

    Dear experts, we have the following requirement - print (preferrably in batch mode) the attached PDF documents from DMS. The documents are located at the content server. To reduce the network load the documents should be accessed directly from the co

  • "Camera is in use by another application" error with built-in iSight

    This message pops up if I try to do video preview in iChat or try to open Photo Booth. There are no other applications running that I can tell and I have unplugged all USB and firewire cables. Also performed a reinstall of bundled software from the T

  • Teststand 4.0 log in password how to reset.

    Hello Teststand gurus, currently I'm using teststand version 4.0. I have set the administrator log in password for the past 2 weeks and I forgot the password. Is there any way to reset it? Thanks guys.  newbie here. Solved! Go to Solution.

  • Dual Layer DVD - Formatting Failed

    I've bene trying to format a dual layerDVD project for the past few hours and I keep getting a Formatting Failed" message and Layer 1 cannot exceed Layer 0 for a OTP disc. I've tried shifting the layer break point all over the place to no avail - is