CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2009
    Posts
    38

    [RESOLVED] Java Bitmap object

    I'm working on a calendar and I want to only display 12 hours at a time in the week view. I have this working now but now I have the problem of changing the hours showing when you scroll up or down. I had this fixed in C# with the Bitmap object but it seems that object isn't available in Java. I have this C# code, could somebody tell me how to get the same effect but then in Java?
    Code:
    if ((this._bMovingEvent == true) && (this._oBitmapBuffer != null))
                {
                    if (this._oBitmap != null)
                    {
                        this._oBitmap.Dispose();
                    }
    
                    this._oBitmap = (Bitmap)this._oBitmapBuffer.Clone(new Rectangle(0, 0, this._oBitmapBuffer.Width, this._oBitmapBuffer.Height), this._oBitmapBuffer.PixelFormat);
                    return Graphics.FromImage(this._oBitmap);
                }
    
                if ((this._oBitmap == null) || (this._oBitmap.Height != this._iScrollMax) || (this._oBitmap.Width != this.ClientRectangle.Width))
                {
                    if (this._oBitmap != null)
                    {
                        this._oBitmap.Dispose();
                    }
    
                    this._oBitmap = new Bitmap(this.ClientRectangle.Width, this._iScrollMax);
                }
    The idea is that if I scroll I change the position of that Bitmap object like so.
    Code:
     e.Graphics.DrawImage(this._oBitmap, 0, -this._iScrollValue);
    Not sure this is the best solution to do it but I don't know any other way, so let me know if this could be easier.

  2. #2
    Join Date
    Aug 2009
    Posts
    38

    Re: Java Bitmap object

    Nobody who can help me?

  3. #3
    dlorde is offline Elite Member Power Poster
    Join Date
    Aug 1999
    Location
    UK
    Posts
    10,163

    Re: Java Bitmap object

    If you just want to scroll an image(?), don't the Graphics & Graphics2D classes give you what you need? See Working With Images.

    It is better to have an approximate answer to the right question than an exact answer to the wrong one...
    J. Tukey
    Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.

  4. #4
    Join Date
    Aug 2009
    Posts
    38

    Re: Java Bitmap object

    Yes, I found the method translate in the Graphics object. Overlooked it at first.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured