Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Code Samples & Tips > Additional Libraries
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Additional Libraries Users contributed libraries.
This sub-forum is only available to licensed users.


Image fade and floodfill library


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2008, 12:37 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,697
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default Image fade and floodfill library

I have knocked up an image fading function for Alfcen (Robert) and included it with my floodfill routine in this small library. No help as its' fairly obvious from the sample app but if you ask for one I'll write one sometime.

For device and desktop but needs .NET 2.0 to provide the image manipulation operations.
Attached Files
File Type: zip FillFade1.1.zip (39.7 KB, 80 views)

Last edited by agraham : 03-06-2008 at 02:52 PM.
Reply With Quote
  #2 (permalink)  
Old 03-06-2008, 07:39 PM
RandomCoder's Avatar
Basic4ppc Veteran
 
Join Date: May 2007
Location: UK
Posts: 485
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Quote:
Originally Posted by agraham View Post
No - only when explicitly passed as a parameter to a library call.

This is a property of the object being drawn on, not of the language. I'm not a graphics person and don't know how this works. I also don't know how the forelayer works in B4PPC. The form background is available to a library by the form image property - whether that image also contains the merged forelayer I don't know. I'd draw on a bitmap from the imagelib library displayed in an image control using only setpixel and getpixel. That gives you a chance to later do the same things with the same logic but as low level pixel work in a library.


P.S. Don't think that I will necessarily write a library for you. As I said above I don't enjoy graphics work and have other things I am doing.
Remember this??
And yet you seem to have become somewhat of an artist

I hope that one day I have the abillity you've got to write whatever code takes your fancy

Regards,
RandomCoder
__________________
Desktop: Pentium D 920 (2.8GHz, 4MB L2 Cache, 800MHz FSB), 1024MB, 256MB Radeon X600, 250GB HD.
Device : Axim X51v XScale 624MHz, 3.7" VGA, 64MB SDRAM, 256MB Flash ROM + 1Gb SD.

"Defeat never comes to any man until he admits it."Josephus Daniels
Reply With Quote
  #3 (permalink)  
Old 03-06-2008, 07:51 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,697
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by RandomCoder View Post
And yet you seem to have become somewhat of an artist
Thanks for the compliment but not really. I distinguish imaging (as in manipulating photos. etc.) from graphics (as in designing and drawing original work). I've been interested in colour imaging on computers for years but totally lack the design flair and imagination to make graphics a worthwhile excercise.
Reply With Quote
  #4 (permalink)  
Old 03-07-2008, 12:20 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Andrew,
For me??? That's fantastic!
Indeed, no help required, your sample is great.
Thanks so much, I will try it tomorrow in my slide show app
and let you know
Reply With Quote
  #5 (permalink)  
Old 03-08-2008, 12:13 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Andrew,
Here is my feedback.
Everything works fine on the desktop. On the device, the transitions
are too slow. Say, a slide show runs in intervals of 5 seconds, while a
transition takes longer than that, the show ends up in a plausible
"out of memory exception". Actually, fading two images on an Image
control is yet faster than fading on a form.

The images to fade are stored in an ImageList:
Fader1.NewFade(il.Item(0),il.Item(1), cBlack, true)
Timer interval 20ms, Faded = Faded + 5 transition steps.
Image sizes are 640 x 480px.
The device, an iPAQ h2210, runs Pocket PC 2003.

Your demo with the much smaller images performs acceptably smooth.

Anyway, a fantastic approach, Andrew. I will experiment further
and eventually find a compromise for the device.

Keep it going

Cheers
Robert
Reply With Quote
  #6 (permalink)  
Old 03-08-2008, 12:34 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,697
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by alfcen View Post
Actually, fading two images on an Image
control is yet faster than fading on a form
I'd sort of expect that as a Form does extra things when assigned a bitmap in order to be able to redraw it.


Quote:
Image sizes are 640 x 480px.
The device, an iPAQ h2210, runs Pocket PC 2003.
Doing fast graphics on a screen that size is a bit ambitious for the processing power of a PPC. Unfortunately I can't speed it up any more and still write in C# as I've optimised it as much as I can. The code that does the work looks like
Code:
 *pixel3++ = (byte)((*pixel1++ * oldpercent + *pixel2++ * newpercent) / 100);
and I can't get it any simpler than that
Reply With Quote
  #7 (permalink)  
Old 03-08-2008, 01:13 PM
alfcen's Avatar
Basic4ppc Veteran
 
Join Date: Apr 2007
Location: Okinawa, Ryukyu
Posts: 424
Awards Showcase
Beta Tester 
Total Awards: 1
Default

Hi Andrew,

Perfectly agreed, processing several steps in an array of 307,200 pixels
in a matter of a second or so is a job for pure C programs.
Your solution is fabulous for the desktop and smaller images in the device!
I will shrink the images to QVGA. They will look fine on a VGA device screen.
Thanks so much for your hard work. I really love the library as it is. And...
you made it for me

Cheers
Robert
Reply With Quote
  #8 (permalink)  
Old 07-01-2008, 10:31 AM
Junior Member
 
Join Date: May 2008
Posts: 24
Default

Quote:
Originally Posted by agraham View Post
... The code that does the work looks like
Code:
 *pixel3++ = (byte)((*pixel1++ * oldpercent + *pixel2++ * newpercent) / 100);
and I can't get it any simpler than that
I'm only qualified to comment having been around for a long time and worked in multiple languages... (By way of saying I'm ignorant of this compiler and of PPC processor architecture!)

But elsewhere, a complex expression like that might entail converting its terms to floating point for the calculation and back again if the assignment were to an integer. This would make it much slower than purely integer computation. Could this be implicated in this case?

Regards, Mike.
Reply With Quote
  #9 (permalink)  
Old 07-01-2008, 11:35 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,697
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by mjcoon View Post
Could this be implicated in this case?
No. Slots on the CLR evaluation stack are either 4 or 8 bytes wide. Depending upon the data types of the operands arithmetic operations are performed as Int32, Int64 or Double operations. Lesser types are promoted to one of these types when copied to the stack and demoted on storage.

In this case Int32 operations are used.
Reply With Quote
  #10 (permalink)  
Old 07-01-2008, 05:07 PM
Junior Member
 
Join Date: May 2008
Posts: 24
Default

Thanks Andrew, that comprehensive and comprehensible answer also sounds very efficient!

Cheers, Mike.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Door library (Beta) - Special library Erel Official Updates 48 07-18-2008 03:33 PM
Fade sur une image GallyHC French Forum 2 05-27-2008 01:01 PM
Desktop Videocam image capture library agraham Additional Libraries 6 05-25-2008 11:00 AM
Image processing library agraham Additional Libraries 13 01-27-2008 12:51 PM
Move an image inside an image control Cableguy Questions & Help Needed 5 05-14-2007 08:40 PM


All times are GMT. The time now is 08:38 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0