problem accessing function in type

BlitzMax Forums/BlitzMax Beginners Area/problem accessing function in type

767pilot(Posted 2006) [#1]
Can somebody pls check the code for my level editor which I am writing.

I have tied mouse button 2 to the save function while I test but I get an error 'unhandled memory exception'.
Also can anyone advise me on anything I may not be doing correctly with the code I have written so far please.

Why also when using masking color 255,0,255 I still have some of that color showing on my image? The main bulk of the color has gone but some still remains!

thanks
Graham


tonyg(Posted 2006) [#2]
Try with debug mode.
Check for anti-alias and that the remaining colours are really 255,0,255 rather than close.
Try the defringe.exe linked to in a post on these forums.


767pilot(Posted 2006) [#3]
already running with debug mode, cant figure out why its stopping where it is

colors are slightly different near the image, will change later

defringe.exe is no longer being hosted by the site, cant find it by google either

any idea to the error please?


tonyg(Posted 2006) [#4]
If the colours are different but close then it's an anti-alias thing. Create the image with transparent background and draw with alphablend or do not use anti-aliased images with non-transparent backgrounds.
You won't need defringe in these cases.
Running that code in debug mode onb my system failed with e:\programming\Blitz\Editor.bmx (or similar) not found.
I don't have an 'e:' drive.


767pilot(Posted 2006) [#5]
why is it referencing E: when I have not coded any paths for that drive. My files are stored there but I would have thought that as long as the directory was moved, and there was no specific path in the code to that drive. then rebuilding the files would run it from the new drive/directory


tonyg(Posted 2006) [#6]
This is in your Editor.blide file :
C:filename=E:\Programming\Blitz\Blitz max\files\Editor\Editor.bmx
while you use FILENAME as a variable.
I have no idea why that would make a difference.

*** Edit *** Try changing the mousedown checks in TMAP.CheckInput to Mousehit checks.


767pilot(Posted 2006) [#7]
ok i have uploaded the code pathed to c:\editor


Dreamora(Posted 2006) [#8]
Problem with your code:

file - Is an object instance

Save, Update etc: functions
Functions are not on instance level but type level.
Due to that, they can't refer to "who" called them and go bogus.

If you replace File by FileData, which is the correct way for calling functions within a type (unless you do it within a method), it won't MAV anymore.

Your whole saving currently is quite wrong.
Because you create instances of something that has no local data. So in the end all XY instances of FileData will save exactly the same stuff as there are no fields and methods, which is the only way to access local (type instance based) data on an object.


767pilot(Posted 2006) [#9]
thanks for the help

I have deleted that load/save type, it turned out to be a big pile of poo

I created Function Save(filename:string) and it works fine with just that.

No need to complicate things for myself especially when there is only ever going to be one instance of the load/save type.


DaveK(Posted 2006) [#10]
"Why also when using masking color 255,0,255 I still have some of that color showing on my image?"

JPEGs use compression, color '255,0,255' (or any other color) will vary slightly throughout the image.

Try using PNGs instead.


simesf(Posted 2006) [#11]
If you're getting green close to the perimeter of the image I'm fairly sure you are using rendered images which were rendered against a magenta background. What happens is that the renderer anti aliases the image you want with the background magenta so you get colours which are a mix of magenta and whatever colour your rendered object is. So if you had a white bit to your object you would get magenta + white = light pink pixels. The mask will only take out pure magenta, leaving you with (in this case) light pink pixels, or magenta + whatever colour your image was.

There are a few things you can do. If by chance you were using the old scanline renderer in 3d Studio max you could check the option to not anti alias against the background. If using another renderer you can render the images with an alpha mask. If you want hard edges or don't want to worry about alpha masks in Blitz try this:
Set your background colour to 57,59,57 and render an alpha image. You will get some anti aliasing to the background colour but it's less pronounced than if you were to use black, and better than livid magenta. Take your image into Photoshop or similar. Select the alpha laver and hit ctrl + L to call up the levels dialog box. Narrrow the maximum and minimum levels to an extreme degree and you will see that the blurred deges become either black or white, giving a hard silhouette to your figure. Experiment with this; the narrow field of levels set to a high value will give a wide edge to your figure & a low value will knock out most of the blurred edges & may even knock out small or narrow parts of your figure, like a gun. When you feel you've found the right level, load this layer as a selection into your main image. If you invert it and hit delete you should take out the background leaving a crisp edge to your figure. Or make sure your the 'rear' colour in your colour selector box is set to magenta and, with the selection active hit (I think) ctrl + backspace. This will flood the area with magenta, leaving you with a hard edge with no pink pixels and a magenta background.