Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to previous messageGo to previous message
mrjt is currently offline  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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Optimized storage of 1BPP images
Next Topic: Drawing and scrolling
Goto Forum:
  


Current Time: Thu Aug 21 08:02:12 CEST 2025

Total time taken to generate the page: 0.04976 seconds