Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Draw stuff [SOLVED]
Re: Draw stuff [message #13907 is a reply to message #13903] |
Fri, 01 February 2008 11:19   |
mrjt
Messages: 705 Registered: March 2007 Location: London
|
Contributor |
|
|
Try this:
// Member variables
Image proba_image;
void LoadImage()
{
ImageBuffer ib( 128, 128 );
for( int y = 0; y < 128; y++) {
RGBA *l = ib[ y ];
for( int x = 0; x < 128; x++) {
// in picture[ ][ ] there is the image
l->a = 255;
l->r = picture[ y ][ x ];
l->g = picture[ y ][ x ];
l->b = picture[ y ][ x ];
l++;
}
}
Premultiply ( ib );
proba_image = ib;
}
void Paint ( Draw& w )
{
w.DrawRect ( GetSize(), White );
w.DrawImage ( 10, 5, proba_image );
}
- I can't think of any reason for MyDraw, what are you trying to achieve?
- The original problem may have been declaring proba_image locally, not as a memeber variable, so that it went out of scope.
- You don't need the imageLoaded flag. It is perfectly safe to draw an empty image, or you can use Image::IsEmpty();
- You probably don't need the picture[] array. You could either read whatever data it is directly into an ImageBuffer or if it is an image file load it directly.
- Premultiply is probably necessary. If the compiler complains then your version of uppsrc may be older than the example (though I'm not sure how that could happen).
Edit: Also it would be helpful if you could use a more descriptve title for new threads. Everything in this topic is 'Draw Stuff'
Hope that helps.
James
[Updated on: Fri, 01 February 2008 12:57] Report message to a moderator
|
|
|
 |
|
Draw stuff [SOLVED]
By: Indio on Fri, 01 February 2008 05:21
|
 |
|
Re: Draw stuff
By: mrjt on Fri, 01 February 2008 11:19
|
 |
|
Re: Draw stuff
By: Indio on Fri, 01 February 2008 16:09
|
 |
|
Re: Draw stuff
By: mrjt on Fri, 01 February 2008 16:44
|
 |
|
Re: Draw stuff
By: Indio on Fri, 01 February 2008 21:38
|
 |
|
Re: Draw stuff
By: mirek on Fri, 01 February 2008 22:42
|
 |
|
Re: Draw stuff
By: Indio on Fri, 01 February 2008 23:41
|
 |
|
Re: Draw stuff
By: mrjt on Tue, 05 February 2008 11:03
|
 |
|
Re: Draw stuff
By: Indio on Tue, 05 February 2008 23:03
|
 |
|
Re: Draw stuff
By: Indio on Fri, 08 February 2008 16:02
|
 |
|
Re: Draw stuff
By: mrjt on Fri, 08 February 2008 17:00
|
 |
|
Re: Draw stuff
By: Indio on Fri, 08 February 2008 18:09
|
Goto Forum:
Current Time: Thu Aug 21 08:02:12 CEST 2025
Total time taken to generate the page: 0.04976 seconds
|