Click to See Complete Forum and Search --> : [RESOLVED] Java Bitmap object


Ultimatum
January 10th, 2010, 09:49 AM
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?
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.
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.

Ultimatum
January 12th, 2010, 04:51 AM
Nobody who can help me?

dlorde
January 12th, 2010, 05:10 AM
If you just want to scroll an image(?), don't the Graphics & Graphics2D classes give you what you need? See Working With Images (http://java.sun.com/docs/books/tutorial/2d/images/index.html).

It is better to have an approximate answer to the right question than an exact answer to the wrong one...
J. Tukey

Ultimatum
January 14th, 2010, 11:18 PM
Yes, I found the method translate in the Graphics object. Overlooked it at first.