Graphics.drawImage not using specified background color

Thanks to everyone in advance -
I have created an image resizing class, with a crop method. The cropping works great, the issue that I am having is the background color that i specify in the drawImage function of Graphics is not working correctly, it defaults to black as the background regardless of what I supply (in this case Color.WHITE). Also, the overlaying image or top most image (comes from a file) is being inverted(i think it is) or otherwise discolored. Here is the code below that I am working with:
Thanks,
Sam
               public void Crop(int Height, int Width, int SourceX, int SourceY) throws Exception {
                    //output height and width
                    int OutputWidth = this.OutputImage.getWidth();
                    int OutputHeight = this.OutputImage.getHeight();
                    //create output streams
                    ByteArrayOutputStream MyByteArrayOutputStream = new ByteArrayOutputStream();
                    MemoryCacheImageOutputStream MyMemoryCacheImageOutputStream = new MemoryCacheImageOutputStream(MyByteArrayOutputStream);
                    //Create a new  BufferedImage
                    BufferedImage NewImage = new BufferedImage(Width, Height, BufferedImage.TYPE_INT_ARGB);
                    Graphics MyGraphics = NewImage.createGraphics();
                    MyGraphics.drawImage(this.OutputImage, -SourceX, -SourceY, OutputWidth, OutputHeight, Color.WHITE, null);
                    // Get Writer and set compression
                    Iterator MyIterator = ImageIO.getImageWritersByFormatName("PNG");
                    if(MyIterator.hasNext()) {
                         //get image writer
                         ImageWriter MyImageWriter = (ImageWriter)MyIterator.next();
                         //get params
                         ImageWriteParam MyImageWriteParam = MyImageWriter.getDefaultWriteParam();
                         //set outputstream
                         MyImageWriter.setOutput(MyMemoryCacheImageOutputStream);
                         //create new ioimage
                         IIOImage MyIIOImage = new IIOImage(NewImage, null, null);
                         //write new image
                         MyImageWriter.write(null, MyIIOImage, MyImageWriteParam);
                    //convert output stream back to inputstream
                    ByteArrayInputStream MyByteArrayInputStream = new ByteArrayInputStream(MyByteArrayOutputStream.toByteArray());
                    MemoryCacheImageInputStream MyMemoryCacheImageInputStream = new MemoryCacheImageInputStream(MyByteArrayInputStream);
                    //resassign as a buffered image
                    this.OutputImage = ImageIO.read(MyMemoryCacheImageInputStream);
               }

Thanks for all your help!
Here is the solution, notice the clear rect:
               public void Crop(int Height, int Width, int SourceX, int SourceY) throws Exception {
                    //output height and width
                    int OutputWidth = this.OutputImage.getWidth();
                    int OutputHeight = this.OutputImage.getHeight();
                    //Create a new BufferedImage
                    BufferedImage NewImage = new BufferedImage(Width, Height, BufferedImage.TYPE_INT_RGB);
                    //create new grapics
                    Graphics2D MyGraphics = NewImage.createGraphics();
                    //set background
                    MyGraphics.setBackground(Color.decode(this.BackgroundColor));
                    //clear rect
                    MyGraphics.clearRect(0, 0, Width, Height);
                    //draw image
                    MyGraphics.drawImage(this.OutputImage, -SourceX, -SourceY, OutputWidth, OutputHeight, null, null);
                    //dispose graphics
                    MyGraphics.dispose();
                    //resassign as a buffered image
                    this.OutputImage = NewImage;
               }

Similar Messages

  • Why does converting word into PDF does not take the background color of the page?

    When I do a page background on a document, and save as pdf, it does not take the background color. It shows only white background.

    This may be a limitation with the built in PDF writer in OS X. Never tried it so I have no idea if it does the same on my Mac.
    As this is not a MS Word problem you are in the right set of forums.
    Have you tried another PDF writer other then the built in one?

  • Since version CS6 (also CC) is not using the "change color" white border

    Hello,
    send you then added a small bug, but the user can very fooled.
    Since version CS6 (also CC) is not using the "change color" white border
    bounded by the selected color. In CS5 it worked correctly.
    More video from here: http://screenr.com/xZxH
    Regards
    Aleš Ulrych

    Hello Mr. Zimmermann,
    thanks for the response. I put it here so that this is a small mistake and knew someday be repaired. I personally find this more troubling issue that I have reported in version CS6: http://forums.adobe.com/thread/1246261?tstart=30
    But I still hope it will be corrected in the future.
    Yours
    Aleš Ulrych

  • Can the current line be highlighted using a background color or have the cursor flash?

    I use the split screen and left click in the Design pane to jump to where I want to be in the Code pane in Dreamweaver CS6. The problem is that it can be very hard to tell where the cursor is in the Code pane since the cursor doesn't flash.
    Is there a way to force Dreamweaver CS6 to change the background color of the currently selected line or at least have the cursor flash in both panes? There must be some way to make it easier to find the current line of code.
    Thanks.

    John Waller wrote:
    The cursor does not flash in Code View only when Code View is not in focus i.e. you're working in the Design View window in Split View.
    In those caases, I just highlight a word or two in Design View and the corresponding words are highlighted by DW in Code View (even when Code view is not in focus).
    Thanks. I've been doing that, but sometimes there is no text to highlight. I hoped Dreamweaver might have a hidden setting that I could enable. That's a lot of extra sliding of the hand/wrist for no good reason when it would be easy for the Dreamweaver programmers to change the background color of the current line or make the cursor flash or do something else to indicate where you are in the code besides making the user constantly make a smearing action with the mouse. All of those extra movements add up the wear and tear when you're trying to avoid getting a repetitive stress injury, especially if you already use mouse gestures in a browser.

  • Tag datwindow property object not functioning in background color

    I am using 12.6 classic
    I need to send to the column's of a Datawindow information to control the properties so that I can dictate the column's background color, The border, etc.
    For example, I use the below to control the background property of a column.
    if( right(customer_name, 1) = 'O', rgb(255,135,155), rgb(255,50,50))
    The problem is that these codes I send with the customer's name display as well.
    My attempted solution was to use the column's tag property
    after sending information to the tag property I want to use the below in the background color of each column.
    if( right(customer_name.tag, 1) = 'O', rgb(255,135,155), rgb(255,50,50))
    but upon saving i get the error                DATAWINDOW
                                                   Expecting true/false expression
    I can also solve the problem even easier if I can just display the tag property of each column in my datawindow, leaving the value of the column to control the background and other column properties.

    Sorry Philip,
    I must have misread your question. When you say tag, we all thought the tag property of the column.  Having re-read the question...
    The problem is that these codes I send with the customer's name display as well.
    you are tagging an O to a column in your select statement to choose a certain background colour, but you don't want to show the letter O.
    You should really select the background colour as a separate column in your results set (refer also to a very similar discussion in PBSAPCN)
    So instead of SELECT customer_name + 'O' .....  SELECT customer_name , 'O' as mybackcolour....
    Then if ( mybaclcolour = 'O' , rgb (....
    Alternatively but not nice and eccentrically unusual, you  could diplay the customer name as a computed column without the last letter: left ( customer_name, len ( customer_name) - 1 )
    HTH
    Lars
    PS Stuart has already suggested this.

  • Graphic styles that use current fill color instead of stomping them?

    Sorry if this is a really stupid, newbie question; I am a stupid newbie.
    If I make a graphic style/appearance, it stores the colors of the fill and stroke and will then stamp that down on whatever else I apply it to (obviously). e.g. if I make a graphic style of a pale yellow fill and a bright orange dropshadow screen to make a glowing neon kind of look, and then drop that style onto a bright blue star, it will make the star pale yellow.
    Is there a way to do a graphic style that _modifies_ the existing appearance instead of stomping it - e.g. dropping that graphic style on my blue star would make a pale blue fill with a bright green dropshadow screen.
    e.g. A graphic style that said "make the new fill 110% value, 85% saturation, same hue as the existing fill color, add a 25 pt dropshadow that has the color of 90% value, 110% saturation, -3 hue of the existing fill color." And then that style dropped on a yellow star and a blue star would result in a glowing neon yellow star and a glowing neon blue star.
    The reason I ask: I have a bunch of geometric shapes of various shades of red, orange, yellow and brown, and would like to see what they would all look like with dropshadows of dark, very desaturated complementary colors (the orange shape gets a dark blue/gray dropshadow, the yellow shape gets a dark purple/gray dropshadow, etc.). Do I have to go in and modify each appearance by hand, or is there some way I can automate that?
    Thanks, and apologies if this is a really obvious question.
    Ken

    You won't get as much control as you describe (specific HSV values), but try putting a negative value in the Drop Shadow dialog's Darkness field.
    To create a Graphic Style that can apply an Effect without disturbing the existing fill/stroke of the object(s), first group the object(s), then apply the Effect (Drop Shadow, etc.) to the Group, and then drag the Group to the Graphic Styles palette.

  • Gnome-keyboard-applet uses wrong background color

    gnome-keyboard-applet always uses white color as a background, even when panel's color is not white.
    (Or, maybe, not exactly white, but it's clearly different from panel's color)
    WTF?

    It seems that this is the problem with theme. I'm using gnome-human-theme from AUR.
    With other murrine themes it's OK. Does somebody know where in gtkrc is the color value, which is responsible for that?

  • CRS 2008 does not use specified datasource

    Using CRS 2008 V1 with SP3
    Using CMC in web browser added a report and specified a datasource however when I view the report CRS is using the datasource saved in the .rpt file instead of the configured datasource.
    Please help as the same reports have to be run against multiple datasources

    Functions for me with CS4, CS5 & CS5.5.
    What are the exact steps that cause this issue?  It looks like you have a document open. Does it happen when you try to define the preset with no other documents open?
    Have you tried resetting your InDesign preferences?

  • InDesign PDF transparent images not printing right background color.

    problem with exporting an InDesign Document to a PDF and printing. My transparent images are showing up with a darker background than what they are placed on. Know how to help?

    Thanks everyone!  That really helped.
    There were a few other things that I had to make sure of also.
    Solution:
    Images placed in InDesign that were made in Photoshop or another program should be in ckmy format.  The background needs to be in the same ckmy.   Transparency blend must be set at CKMY, then Transparency Flattener presents must be set at Rasters/Vectors: 0 Line art and text resolution: 600, Gradient and mesh resoltuion 300.  Exporting to PDF must be done under present PDF/X-4:2008 Compatibility: Acbrobat 7.

  • MOVED: Graphics cards not using correct generation of PCIe

    This topic has been moved to GAMING Motherboards.
    https://forum-en.msi.com/index.php?topic=253322.0

    Quote from: jdthedj69 on 19-February-15, 09:12:38
    Well see that's the weird thing, I've read a little about this and a lot of people have it switch when the render test runs because of power saving features in the graphics cards and such, but mine does the opposite, it starts in 3.0 and within 5 to 10 seconds switches down to 1.1.
    if the freq. drops, it will also drop the gen version, its power saving feature of the card
    stress the card with furmark or better render then watch out the gen version

  • Div background color not showing in Internet Explorer 8 and before

    My Footer div is not showing the background color (supposed to be black...)  in Internet Explorer 8 and earlier.  It's assuming the body color instead.  Also the border color on top of the 'bubbles' that run across the page is wrong (supposed to be blue)    Is this just because Internet Explorer 8 and earlier did not support div background and border colors yet, or is there a work-around??  Or maybe I did something wrong?
    The site is:    www.meridianwaterfiltration.com

    martcol wrote:
    I don't think that IE8 does rgba.
    It should be OK with rgb but not rgba.
    Martin
    No its doesnt
    I'd just use a hexidecimal color - black #000 and blue: #03f (see below)
    .footer {
    position: relative;
        width: 100%;
        padding-top: 0px;
        padding-right: 0;
        padding-bottom: 0px;
        padding-left: 0;
        background-image: none;
        background-repeat: repeat-x;
        margin-top: 0px;
        clear: both;
        height: 350px;
        background-color: #000;
    #bubble {
        background-image: url(Images/water drop 0banner.jpg);
        background-repeat: repeat-x;
        width: 100%;
        height: 43px;
        border-top-width: 3px;
        border-top-style: solid;
        border-top-color: #03F;
        margin: 0px;
        padding: 0px;
        background-color: #3FF;

  • Why is the background color not applied in one case?

    Hi,
    I'm using RH 7 and WebHelp.
    I apply a TableHeading style to the first row of my tables. The TableHeading style is supposed to fill the cells of the first row with a background color of blue, and the text is in white. It works fine except for one table. I think TableHeading style was not applied in the Word document when I imported this topic. I tried to apply the TableHeading style to the first row, and it says it is applied in the HTML. But, the background blue does not fill the cells.
    Here is what I am trying to achieve:
    Here is my problem table:
    I can see in the HTML that the background color is not present in the code. Here is the code for the example that is correct:
    <p class=TableHeading>Chapter</td>
    <td style="border-left: none; border-right: solid #000000 1.0px; border-top: solid #000000 1.0px; border-bottom: solid #000000 1.0px;
              width: 279.4pt; padding: 0in 5.4pt 0in 5.4pt; background-color: #003399;"
    bgcolor=#003399 width=279.4pt>
    <p class=TableHeading>Description</td></tr>
    <tr><td style="x-cell-content-align: top; border-left: solid #000000 1.0px; border-right: solid #000000 1.0px; border-top: none;
                       border-bottom: solid #000000 1.0px; width: 182.85pt; padding: 0in 5.4pt 0in 5.4pt;
                       padding-left: 0px; padding-top: 0px; padding-right: 0px;
                       padding-bottom: 0px;" valign=top width=182.9pt>
    Here is the code for my problem table:
    <p class=TableHeading>Activity</td>
    <td style="border-left: none; border-right: solid #000000 1.0px; border-top: solid #000000 1.0px; border-bottom: solid #000000 1.0px;
              width: 168.0pt; padding: 0in 5.4pt 0in 5.4pt;" width=168pt>
    <p class=TableHeading>Keyboard Shortcut</td></tr>
    <tr style="x-cell-content-align: center;" valign=middle>
    <td style="width: 374px; x-cell-content-align: top; border-left: solid #000000 1.0px; border-right: solid #000000 1.0px;
              border-top: none; border-bottom: solid #000000 1.0px; padding: 0in 5.4pt 0in 5.4pt;
              padding-left: 0px; padding-top: 0px; padding-right: 0px;
              padding-bottom: 0px;" valign=top width=374px>
    Here is the code from the CSS:
    p.TableHeading {
    background-color: #003399;
    punctuation-wrap: simple;
    text-autospace: none;
    font-size: 10.0pt;
    font-weight: bold;
    color: #ffffff;
    font-family: Verdana, sans-serif;
    margin-left: 3pt;
    margin-right: 3.0pt;
    line-height: 120%;
    margin-top: 0pt;
    margin-bottom: 0pt;
    LI.p-TableHeading {
    punctuation-wrap: simple;
    text-autospace: none;
    font-size: 10.0pt;
    font-weight: bold;
    color: #ffffff;
    font-family: Verdana, sans-serif;
    line-height: 120%;
    Any suggestions?
    Thanks,
    Julie
     I don't understand why the TableHeading style is not applying the background color for the one table. I'm guessing I could just add it to the code using the HTML editor. However, I wasn't sure if that was the best way to fix this problem or if I would create another problem.

    Hi Willam,
    Thanks for your answer, and I will go ahead and add the background color to the problem table.
    However, I am still puzzled as to why the background color is applied to the cells in the other tables and not the problem table. I'm not sure what I did to cause the problem - how I applied the TableHeading to the table cell in one case and not the other. Any ideas how I can avoid this problem?
    I will not use the Word documents going forward and will only make changes with the RH editor.
    Thanks again,
    Julie

  • Background color for column heading

    Hi,
    I have 5 columns in my report and I would like to have different background color for column headings. How can I do this in report templates?
    I was looking at Column heading section-
    <th class="t10ReportHeader"#ALIGNMENT# id="#COLUMN_HEADER_NAME#">#COLUMN_HEADER#</th>
    How can I specify backgrund colors for all columns here?
    Thanks in advance

    G'day Karen,
    Thanks for ur reply.
    I have seen this note before, its not that the header colors have changed after latest SP was applied in our systems. Also the ABAP and JAVA stacks are in sync.
    Scenario is that we are trying to set up a new Portal theme for Enterprise Reporting with some specific color codes (hex codes).
    What i have observed is Characterstics Header background color is set up using the element "Background Color of Level 1 Column Heading ".
    While the Background color for Key Figures header is using element "Background Color of Level 2 Column Heading ".
    But the problem is element "Background Color of Level 2 Column Heading " is also used as the Background color for Standard Characterstics cell, so if we make it same the whole report of the same color, which we dont want.
    Requirement is to get the same Background color for Header cells (both Char. and Key Figure headers).
    Any further suggestions will be appreciated.
    Thanks
    CK

  • Applying different background colors to selected paragraphs

    Hello there,
    In the text that is loaded dynamically as XML (i.e. markup format) I need to specify background color for selected paragraphs.
    So, I tried this: <p backgroundColor='#800000'>.
    Alas, it has no effect.
    What puzzles me even more is that declaring this attribute in span DOES work:
    <p><span backgroundColor='#800000'>Lorem impsum ... </span></p>
    This way it does change the background color, albeit, it is not solid background but sort of highlight of the text lines.
    Although, it's not ideal, I could live with that, but still would be interested to find out: what am I missing?
    After all, span can't have children, so it is a patch rather then nice solution.
    So, far I couldn't find the explanation of that behavior - ignoring 'backgroundColor' attribute in the paragraph tag.
    I'm on Mac 10.6.6 and use TLF 2.0 build 228
    BTW, searching for an answer I found a typo in the official TLF 1.1 Markup specification that was published back in December:
    6.3.13 backgroundColor attribute
    <xs:attribute name="textAlpha" type="xs:text" default=" transparent"/>
    Background color of the text.
    backgroundColor is non-inheriting.
    Valid values include:
    • transparent: No color is applied.
    • <hexadecimal value>: A value that conforms to the color data type.
    Thanks,
    Igor Borodin

    Here is the app and the screen shot of the runtime error:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark" >
    <fx:Script>
    <![CDATA[
    import spark.utils.TextFlowUtil;
    XML.ignoreWhitespace = false;
    [Bindable]
    private var txtXML:XML = <TextFlow version="2.0.0" xmlns="http://ns.adobe.com/textLayout/2008" fontSize='18' >   
        <p>
    <g>Lorem ipsum dolor sit amet,
    <span color='#880000'>consectetur adipiscing elit.</span>
    Quisque tempus, eros ac dignissim interdum, elit sem euismod velit,
    <span fontStyle='italic'>eget laoreet urna metus nec enim.</span>
    </g>
    </p>
    </TextFlow>
    ]]>
    </fx:Script>
    <s:RichText horizontalCenter="0" verticalCenter="0" width="200"
    textFlow="{TextFlowUtil.importFromXML(txtXML)}" />
    </s:Application>
    I'm on Mac 10.6.6 Flex Hero 4.5 TLF 2.0 build 228
    It's the same on Safari and FireFox
    HTH,
    Igor Borodin

  • WorkOrderList TileView Row & Selected Row Background Color Change

    Hi,
         can we change the background color of WorkorderList TileView Row & Selected Row Background color ?. Actually i am trying to change the color of both in WorkOrderList but it not reflecting any color on my Agentry client. I used a style on Tile List View Data/Style.
    but these applied style on Rows & Selected Rows are not working in Agentry client.
    if any other alternate solution exist in Agentry, please guide me.
    i am using following...
      sap mobile platform-2.3.3
    Thanks & Regard
    Manish Kumar
    Tags edited by: Michael Appleby

    Hi Jason
          Yes using Image we can achieve that goal but i want to use a background color instead of Image background. Finally I used a background color on label and set the that label field on Screen. And It's showing the background color on WorkOrderList Row & Selected Row that what i wanted. But on both Row & Selected TileView Screen showing white outline that i don't want and also i could not remove the default Selected Blue Background Color.
         Please guide me how to remove white outline and default Blue Selected Background color.
    Thanks & Regard
    Manish Kumar

Maybe you are looking for

  • Process LOADING has no predecessor in Process chain

    Hi Experts, I have copied Process chain with all process and I have included new steps in process chain like change log deletion  and delete & create index(the process chain has data mart functionality which mean that, first it load to DSO and then f

  • Itunes/ipod adding song problem

    everytime i go to add songs, it wont let me, and under my ipod where it says music, when i click it, the font is not bold but lightened and i cant add songs nor delete any, how do i fix it? thanks

  • Application cache removed with Clear Data

    I'm developping a tool on ipad which I want to run with application cache only according Safari's "Storing Data on the Client". and: "Safari Client-Side Storage and Offline Applications Programming Guide" But I observed that the app cache is deleted

  • Any BAPI s or functional modules avilabe for Create BOM  -- CS01

    client using ECC6.0  ,, Actually we are converting legacy data (Excel) in to SAP R/3 . we are writing BDC program for this. Any functional modules or BAPI are avilabe for convert data in to SAP R/3 for CS01 transaction. If any one know exact informat

  • Zen Touch - Unable to scroll

    I know this topic was addressed in an earlier thread, but I was unable to read the entire thread (see "Zen Touch- Can't Scroll Up!?!?). Hoping somebody can help me out My Zen Touch will not allow to scroll up. It even scrolls down when I want to go u