on 23-04-2012 05:57 AM
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,wid th,height);
graphics.SwapBuffers ();
}
}
Solved! Go to Solution.
on 23-04-2012 06:25 PM
Maybe, my question was solved by code in "Pss/sample/Graphics/PrimitiveSample". Thanks!
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を一度ログアウトし、再度ログインしてください。


Website ©2013 Sony Computer Entertainment Europe
All content, game titles, trade names and/or trade dress, trademarks, artwork and associated imagery are trademarks and/or copyright material of their respective owners. All rights reserved. [more info]
%%http://community.eu.playstation.com/t5/Announcements/Beta-Trial-Information/td-p/11386362
best_shooter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_driver.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_performer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_footballer.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_fighter.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_creator.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
best_action_player.png%%http://community.eu.playstation.com/t5/Announcements/Introducing-Best-of-PlayStation/td-p/13741979
dev2.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Producer-and-Developer-Ranks/td-p/18407352
trophy.gif%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/The-Community-Awards-FAQ/td-p/18407096
PSlogoSM.png%%http://community.eu.playstation.com/t5/Website-and-Forum-Help-Feedback/Online-Support-Coordinator-rank/td-p/18414870