|
-
January 10th, 2010, 10:49 AM
#1
[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.
-
January 12th, 2010, 05:51 AM
#2
-
January 12th, 2010, 06:10 AM
#3
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.
-
January 15th, 2010, 12:18 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|