How to to draw an image ?

Feb 19, 2012 at 12:50 PM

How would one draw an existing image to the screen ?

Like i have some images that represents the toolbar etc...

how to draw them on the screen.

Feb 19, 2012 at 2:54 PM

Do you mean a .png image or similar?

Developer
Feb 19, 2012 at 3:55 PM

A .png image would require a working deflate algorithm that works in Cosmos. I do have a working png loader in C# in Orvid.Graphics, provided the deflate algorithm works in Cosmos. (.jpg is much more complex, and it's interface usage means it most likely won't work in Cosmos)

The .bmp image loader is much more likely to work, so I would suggest trying it first.

Feb 19, 2012 at 3:58 PM

I was going to suggest converting it beforehand with one of the converters such as cosmosconverter.codeplex.com or caic.codeplex.com .

Feb 19, 2012 at 6:09 PM

thanks for the info

i'm going to give it a try with an .bmp

Feb 19, 2012 at 8:55 PM
Aurora01 wrote:

I was going to suggest converting it beforehand with one of the converters such as cosmosconverter.codeplex.com or caic.codeplex.com .

Hey CIAC is mine! =) Its outdated, I should go through and built it for the Current Cosmos source. - Matt

Feb 20, 2012 at 1:56 PM

i have used thz cosmos converter to convert my load.bmp image,

now i have the .cs file what do have to do now to draw it on the screen ?

Thn aksn!

Feb 20, 2012 at 2:13 PM
civilwarrock wrote:
Aurora01 wrote:

I was going to suggest converting it beforehand with one of the converters such as cosmosconverter.codeplex.com or caic.codeplex.com .

Hey CIAC is mine! =) Its outdated, I should go through and built it for the Current Cosmos source. - Matt

I was actually helping you by recommending your project, but if you don't want me to... :)

-Aurora

Feb 20, 2012 at 2:15 PM
HD2HD wrote:

i have used thz cosmos converter to convert my load.bmp image,

now i have the .cs file what do have to do now to draw it on the screen ?

Thn aksn!

There should be a method in there, I'm not sure what it's called, but just run that

-Aurora

Feb 20, 2012 at 2:16 PM

i did that but then it gave me an error , i think i need to reference to an .dll

Feb 20, 2012 at 2:21 PM

it gave me this error:

Error	1	Method not found: 'Void Cosmos.Hardware.VGAScreen.SetPaletteEntry(Int32, Byte, Byte, Byte)'.
   at System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount)
   at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveMethod(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at Cosmos.IL2CPU.ILReader.ProcessMethod(MethodBase aMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILReader.cs:line 328
   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, Object sourceItem) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 826
   at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 955
   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 316
   at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 249	C:\Program Files\MSBuild\Cosmos\Cosmos.targets	32	10	VORTEXBoot
Feb 20, 2012 at 2:24 PM

Oh yes, it was written for an older version of Cosmos, I think at the start of the function you need to put this:

Cosmos.Hardware.VGAScreen VGAScreen = new Cosmos.Hardware.VGAScreen();

Feb 20, 2012 at 2:25 PM

thanks i will try it

Feb 20, 2012 at 2:33 PM
HD2HD wrote:

thanks i will try it

No problem.

-Aurora

Feb 20, 2012 at 2:51 PM

no it's still the same error it gives me.

Feb 20, 2012 at 2:55 PM

isn't there another way to draw an image to the screen ?

Feb 20, 2012 at 3:14 PM

Maybe, have you tried the other converter that I mentioned?

Feb 20, 2012 at 3:34 PM

yes it didn't worked 

application has stopped working error

Feb 20, 2012 at 3:36 PM

Then you're starting to run out of options...

-Aurora

Feb 20, 2012 at 3:40 PM

yes i know , i'm getting tired of all this irritating error shit 

Feb 20, 2012 at 3:41 PM

the error in vs it says it is in a file called 

cosmos.targets i can't find that file anywhere 

Feb 20, 2012 at 3:54 PM

Could you post the exact error for me please?

-Aurora

Feb 20, 2012 at 3:55 PM

 

Error	1	Method not found: 'Void Cosmos.Hardware.VGAScreen.SetPaletteEntry(Int32, Byte, Byte, Byte)'.
   at System.ModuleHandle.ResolveMethod(RuntimeModule module, Int32 methodToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount)
   at System.ModuleHandle.ResolveMethodHandleInternalCore(RuntimeModule module, Int32 methodToken, IntPtr[] typeInstantiationContext, Int32 typeInstCount, IntPtr[] methodInstantiationContext, Int32 methodInstCount)
   at System.ModuleHandle.ResolveMethodHandleInternal(RuntimeModule module, Int32 methodToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveMethod(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at Cosmos.IL2CPU.ILReader.ProcessMethod(MethodBase aMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILReader.cs:line 328
   at Cosmos.IL2CPU.ILScanner.ScanMethod(MethodBase aMethod, Boolean aIsPlug, Object sourceItem) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 826
   at Cosmos.IL2CPU.ILScanner.ScanQueue() in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 955
   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod) in c:\Data\Sources\Cosmos\source2\IL2CPU\Cosmos.IL2CPU\ILScanner.cs:line 316
   at Cosmos.Build.MSBuild.IL2CPUTask.Execute() in c:\Data\Sources\Cosmos\source2\Build\Cosmos.Build.MSBuild\IL2CPUTask.cs:line 249	C:\Program Files\MSBuild\Cosmos\Cosmos.targets	32	10	VORTEXBoot
Feb 20, 2012 at 3:55 PM
Edited Feb 20, 2012 at 3:56 PM

 

NO

Feb 20, 2012 at 3:59 PM

It seems like Cosmos can't find VGAScreen. Check if you can use this code in your kernel:

Cosmos.Hardware.VGAScreen vga = new Cosmos.Hardware.VGAScreen();

vga.SetMode320x200x8();

vga.SetPaletteEntry(0,0,0,0);

vga.Clear(0);

Feb 20, 2012 at 4:00 PM

i can use that code

Feb 20, 2012 at 4:01 PM

I think the converters are broken. You should be able to use some sort of array drawing, just let me get some code

Feb 20, 2012 at 4:02 PM

heres the link to image 

http://www.mediafire.com/?iachbdb0haz8ink

Feb 20, 2012 at 4:05 PM

What are all of those strange references?

Feb 20, 2012 at 4:06 PM

where under VORTEX ?

Feb 20, 2012 at 4:06 PM

Such as Cosmos.Maths, Cosmos.Graphics.Inporter etc.

Feb 20, 2012 at 4:08 PM

they came with the converter i

needed to import them so the the loadimg.cs coould use it beacuse it used those references

Feb 20, 2012 at 4:10 PM
HD2HD wrote:

they came with the converter i

needed to import them so the the loadimg.cs coould use it beacuse it used those references

Let me have a look at the converter...

Feb 20, 2012 at 4:11 PM
Aurora01 wrote:
HD2HD wrote:

they came with the converter i

needed to import them so the the loadimg.cs coould use it beacuse it used those references

Let me have a look at the converter...

Go onto downloads and use version 2.8, it seems more stable

Feb 20, 2012 at 4:15 PM

i already used that version but when i need to give a name to the file that will contain the code ,whatever is use

it gives me an error that the file is not supported.

Feb 20, 2012 at 4:17 PM

If you put your image on mediafire, I could convert it and send you the code back :)

-Aurora

Feb 20, 2012 at 4:20 PM

thanks for doing that i will upload it asap

Feb 20, 2012 at 4:20 PM

heres the link

http://www.mediafire.com/?41fobn3cv7plkv3

Feb 20, 2012 at 4:24 PM
HD2HD wrote:

heres the link

http://www.mediafire.com/?41fobn3cv7plkv3

Just converting it...

Feb 20, 2012 at 4:32 PM

cosmos-tutorials.webs.com/cosimg.cs

Feb 20, 2012 at 4:35 PM

and it's only the .cs file i need ?

Feb 20, 2012 at 4:41 PM
HD2HD wrote:

and it's only the .cs file i need ?

Just copy the code into a function

Feb 20, 2012 at 4:55 PM

it sure takes a long time to build them project

Feb 20, 2012 at 4:56 PM
HD2HD wrote:

it sure takes a long time to build them project

That's the problem with an image with about 65,000 lines

-Aurora

Developer
Feb 20, 2012 at 4:58 PM
Edited Feb 20, 2012 at 4:59 PM

Just to make a request for the benefit of all devs (who receive an email every time a message is posted in a discussion :P (I woke up to 60 new emails from cosmos :P)), Could you move such a fast-moving conversation onto the IRC rather than the discussion forums?

Feb 20, 2012 at 5:01 PM
blah38621 wrote:

Just to make a request for the benefit of all devs (who receive an email every time a message is posted in a discussion :P (I woke up to 60 new emails from cosmos :P)), Could you move such a fast-moving conversation onto the IRC rather than the discussion forums?

Blah: If you don't like the e-mails, can't you just disable them?

Developer
Feb 20, 2012 at 5:03 PM

I can, but then I have to repeatedly check the discussion forum to see if something new has been posted. With the emails, I'm also able to respond much quicker, because I receive the email right after the message is posted.

Feb 20, 2012 at 5:04 PM

True, maybe you could filter them into a special folder or something?

Developer
Feb 20, 2012 at 5:05 PM

I already have them filtered to a specific folder. There was only 5 that weren't from Cosmos :P

Feb 20, 2012 at 5:07 PM

Only 5! Oh well

Feb 20, 2012 at 5:13 PM

i'm going to eat for a while , then it should be ready and then i could tell if it worked !

 

Thanks for helping !

Feb 20, 2012 at 5:16 PM

ok

Feb 20, 2012 at 6:12 PM

thanks very much it worked !

only is the image pixelated because i made it originally 320x200 if i made a new image but 

with a larger resolution would it be better ?

Developer
Feb 20, 2012 at 8:29 PM

It isn't because of the image size. Don't make it a larger resolution or you will just make more problems for yourself.

I think its because it has way too many colours for the 256 colour resolution we have.

Feb 20, 2012 at 8:33 PM

before it was .png it had it saved as a 256 .bmp

Developer
Feb 21, 2012 at 4:01 AM

Oh ok then. Ha ha ha ha silly me

Mar 1, 2012 at 10:51 AM

I converted the image into a file.cs but i don't know how to print it on the screen.

HELP please.

Jun 2, 2013 at 5:26 AM
Edited Jun 2, 2013 at 5:27 AM
Look ahmedyosrihamdy,
I had the same problem first.
Here are some tips:
1- Use VGA Screen not Text Screen

2- Use the version 2.8 of the convert software- it is more stable

Here are some codes helpin' u understand better:
using System;
using System.Collections.Generic;
using System.Text;
using Sys = Cosmos.System;
using Cosmos.Hardware;

namespace oS
{
    public class Kernel : Sys.Kernel
    {
        VGAScreen screen;
protected override void BeforeRun()
        {
            screen = new VGAScreen();
            screen.SetMode320x200x8();
            screen.Clear(0);
            while (true)
            {
                Run();
            } 
        }
protected override void Run()
        {
         ///Paste the code of the .cs file that the converter creates for u
         ///Example:screen.SetPaletteEntry(847977, 84, 79, 77);
            screen.SetPaletteEntry(837774, 83, 77, 74);
            screen.SetPaletteEntry(867975, 86, 79, 75);
            screen.SetPaletteEntry(857773, 85, 77, 73);
            screen.SetPaletteEntry(807469, 80, 74, 69);....
            screen.SetPixel320x200x8(637, 273, 000);
            screen.SetPixel320x200x8(638, 273, 000);


        }
    }
}