Graphics

Reply
Accepted Solution

How to draw images using pixel data?

I want to draw images using pixel datas. And I found a function "ReadPixels()". But I don't know how to use this, and how to make the byte array .

 

For example, the 2D pixel data matrix 2*2 (r,g,b,a) is as follow

 

{[(100,100,100,100), (100,100,100,100)],

[(100,100,100,100), (100,100,100,100)]}

 

how should I program?

 

 

Thanks;

 

 

The following is my uncompleted code.

 

public class AppMain
	{
		private static GraphicsContext graphics;
		
		private static int width;
		private static int height;
		
		public static void Main (string[] args)
		{
			Initialize ();

			while (true) {
				SystemEvents.CheckEvents ();
				Update ();
				Render ();
			}
		}

		public static void Initialize ()
		{
			graphics = new GraphicsContext ();
			
			width = 300;
			height =300;
		}

		public static void Update ()
		{
			// Query gamepad for current state
			var gamePadData = GamePad.GetData (0);
		}

		public static void Render ()
		{
			// Clear the screen
			graphics.SetClearColor (1.0f, 1.0f, 1.0f, 1.0f);
			graphics.Clear ();
			
			byte [] array = new byte [width*height*4];
			for(int y=0;y<height;y++){
				for(int x=0;x<width;x++){
					array[4*(x + y*width)] = 50;
					array[4*(x + y*width)+1] = 100;
					array[4*(x + y*width)+2] = 150;
					array[4*(x + y*width)+3] = 0;
				}
			}
			
			graphics.ReadPixels(array,PixelFormat.Rgba,0,0,width,height);
			graphics.SwapBuffers ();
		}
	}

 


Please use plain text.

Re: How to draw images using pixel data?

Maybe, my question was solved by code in "Pss/sample/Graphics/PrimitiveSample". Thanks!

Please use plain text.
This widget could not be displayed.
Announcements

Welcome to the PlayStation Mobile Developer Forums


This is a community for the discussion of technical topics with other developers and SCE engineers. Posting ideas/requests are also appreciated. Join the discussion!

PlayStation®Mobile開発者フォーラムでは世界中の開発者の皆様と一緒に、議論や情報交換が可能です。SCEも議論に参加し、皆様の開発をサポートします。アイデアやリクエストも大歓迎です。ぜひご参加ください。

PSM Developer Registration (for free) on PSM DevPortal is required to post on the forum.
Please sign out then sign in again to the forum and PSM DevPortal after you have completed the registration.

フォーラムへ投稿をするにはPSM DevPortalへの登録(無料)が必要です。
登録後はフォーラムと PSM DevPortalを一度ログアウトし、再度ログインしてください。






Recent News