Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Request for SetPixel in Form object.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-31-2007, 12:00 PM
Junior Member
 
Join Date: Oct 2007
Location: Italy
Posts: 25
Default Request for SetPixel in Form object.

Please Erel, adds the SetPixel method (to change the color of a pixel) to Form object!!!

The Line method don't works correctly for some applications!

Thank you!
__________________
HP HW6915 240x240 - Windows Mobile 5.0
Reply With Quote
  #2 (permalink)  
Old 12-31-2007, 12:10 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by forisco View Post
Please Erel, adds the SetPixel method (to change the color of a pixel) to Form object!!!
As a workaround you could try Line(x,y,x+1,y+1,color)

Quote:
The Line method don't works correctly for some applications!
Example?
Reply With Quote
  #3 (permalink)  
Old 12-31-2007, 01:09 PM
Junior Member
 
Join Date: Oct 2007
Location: Italy
Posts: 25
Default

I'm working to my project GraPPC, a graphic program.

For the method FloodFill (fill an area with a color) i need to set the color for a single pixel but with the Line method i have some problems. For example, for this method i must to control the color of the adjacent pixels for any pixel and if i use the Line method i cover this pixels!

This is my work in progress :
Attached Files
File Type: zip FlooFill.zip (7.0 KB, 12 views)
__________________
HP HW6915 240x240 - Windows Mobile 5.0
Reply With Quote
  #4 (permalink)  
Old 12-31-2007, 01:31 PM
Junior Member
 
Join Date: Oct 2007
Location: Italy
Posts: 25
Default

I tryed to use the SetPixel method from the ImageLib library but i have the same problem : two pixel for each point! Why?
This is my code (bmp is a BitMap object):

Code:
Sub App_Start
	Form1.Show
	bmp.New2(Form1.Width,Form1.Height)

End Sub

Sub Form1_MouseDown (x,y)
		bmp.SetPixel(x,y,cRed)
		Form1.Image = bmp.Value
	
End Sub
__________________
HP HW6915 240x240 - Windows Mobile 5.0
Reply With Quote
  #5 (permalink)  
Old 12-31-2007, 02:52 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 817
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

I added a Pen function to your program using the
bmp.SetPixel to show that it works

You needs to add Form1.Refresh
without the refresh function it does not work.

In your case you should copy the bitmap and refresh only after the end of the fill function.

Form1.Line(x,y,x+1,y+1,color) gives a line of two pixels.

Anyway the SetPixel function for the Form would be nice.

Klaus
Switzerland
Attached Files
File Type: zip floogfill_1.zip (7.5 KB, 8 views)
Reply With Quote
  #6 (permalink)  
Old 12-31-2007, 03:21 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Using your code of SetPixel on a bitmap from ImageLib I too get two pixels. But they are not actually two solid pixels. Looking at them using the Magnifier tool I can see that they are combinations of two or more shaded (not solid colour) pixels. I don't fully understand what is happening here but the reason for this seems to be that although the bitmap is nominally the same size of the form in fact it is not! You can see this by clicking on the right side of the form and noticing that the pixel(s) do not appear under the mouse pointer. The pixels are being stretched in mapping the bitmap onto the form.


You can in fact get a single pixel by adding the BF parameter to Line

Form1.Line(x,y,x+1,y+1,color,BF)

I don't remember having to add this before but maybe my memory is at fault!

EDIT :- Something HAS changed. My FormEx library uses something similar to provide a SetPixel function and it is now broken and produces two pixels? I wonder what has changed?

Last edited by agraham : 12-31-2007 at 03:31 PM.
Reply With Quote
  #7 (permalink)  
Old 12-31-2007, 06:07 PM
Junior Member
 
Join Date: Oct 2007
Location: Italy
Posts: 25
Default

Klaus, if i use your Pen function in my FloodFill function i receive an error : Windows close the B4PPC with a standard message!!!
And it happen the same thing with the Line method suggested by agraham!!!

For me, the problem is in the memory management of B4PPC. The recoursive method that i use for FloodFill function use a lot of memory. In Visual Basic 6 for Windows i obtain the same result if i use a large area to fill; if i use a small area all works fine.

A question : it's possible to increase the memory used by B4PPC? Or it uses yet the maximum of available RAM memory?

Note : with my code almost all works fine : with a SetPixel function for the Form i'm sure of solve my problem.
__________________
HP HW6915 240x240 - Windows Mobile 5.0

Last edited by forisco : 12-31-2007 at 06:10 PM.
Reply With Quote
  #8 (permalink)  
Old 12-31-2007, 06:19 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by forisco View Post
The recoursive method that i use for FloodFill function use a lot of memory.
The problem is not a lack of memory per se but you are running out of stack space on the device. I think that your only solution is to write a non-recursive routine.
Reply With Quote
  #9 (permalink)  
Old 01-01-2008, 03:30 PM
klaus's Avatar
Basic4ppc Expert
 
Join Date: Oct 2007
Location: Switzerland
Posts: 817
Awards Showcase
Beta Tester Competition Winner 
Total Awards: 2
Default

I tested the different possibilities of the line function.
It seems having a somewhat strange behaviour:
Line(x,y,x+1,y+1,color) gives a line of two pixels
Line(x,y,x+1,y+1,color,B) gives a square of four pixels
Line(x,y,x+1,y+1,color,BF) gives a single pixel ?
Attached some examples.

I have found some interesting articles about filling polygons with non recursive methods.

http://www.cs.rit.edu/~icss571/filling/index.html

http://alienryderflex.com/polygon_fill/

I have not yet looked in details, neither tested these methods, but hope they could be helpfull.
I am also looking for a fill method for my IconEdit program.

Klaus
Switzerland
Attached Images
File Type: gif Line.gif (8.5 KB, 7 views)
Reply With Quote
  #10 (permalink)  
Old 01-01-2008, 04:08 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 1,900
Awards Showcase
Beta Tester Forum Contributer 
Total Awards: 2
Default

Quote:
Originally Posted by klaus View Post
It seems having a somewhat strange behaviour:
Line(x,y,x+1,y+1,color) gives a line of two pixels
Line(x,y,x+1,y+1,color,B) gives a square of four pixels
Line(x,y,x+1,y+1,color,BF) gives a single pixel ?
It's not so strange if you know what the underlying .NET functions do.

Line(x1,y1,x2,y2,color) Draws a line from x1,y1 to x2,y2. This is the one whose behaviour seems to have changed for me but it is a .NET change not a B4PPC change as it happens in my FormExDesktop libarary which calls .NET directly. Previously it seemed to draw a line from x1,y1 to x2-1,y2-1 which gave a single pixel. Now it behaves as it is documented "Draws a line connecting two Point structures".

Line(x1,y1,x2,y2,color,B) Draws the single pixel border of a rectangle defined by x1,y1, and x2,y2. So four pixels in the minimum case.

Line(x1,y1,x2,y2,color,BF Fills the INTERIOR of a rectangle defined by x1,y1, and x2,y2. So theoretically 0 pixels in the minimum case but it seems to default to 1 pizel located at x1,y1. Actually it always starts the fill at x1,y1 rather than x1+1,y1+1 so you could argue that it is buggy although it IS documented to behave this way.

Last edited by agraham : 01-01-2008 at 04:17 PM.
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
request for squeeling counter demo! colin9876 Questions & Help Needed 25 05-21-2008 11:25 PM
Object Reference not set to an instance of an object monster9999 Questions & Help Needed 9 01-15-2008 10:56 PM
HTTP maximum request size and method problems willisgt Questions & Help Needed 1 08-27-2007 08:10 PM
Tutorial Request - How to creat B4P library? conf Questions & Help Needed 5 06-25-2007 12:26 PM
SetPixel do no work Put Claude Questions & Help Needed 1 05-14-2007 06:21 AM


All times are GMT. The time now is 05:25 PM.


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