1
comment utiliser la fonction setPixel dans iphonecomment utiliser la fonction setPixel dans iphone
comment utiliser la fonction setPixel dans iphonecomment utiliser la fonction setPixel dans iphone
Si vous dessinez un UIView, je ne crois pas qu'il y ait un moyen de définir un pixel individuel. Au lieu de cela, essayez d'utiliser CoreGraphics en remplaçant votre méthode de UIView drawRect:
:
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect pixelRect;
pixelRect.x = 100; // or whatever position needs a pixel drawn
pixelRect.y = 100;
pixelRect.width = 1;
pixelRect.height = 1;
CGContextSetRGBFillColor(ctx,1,1,1,1.0); // just fill with a white color
CGContextFillRect(ctx, pixelRect);
Une autre approche peut être envisager d'utiliser des points OpenGL et le dessin juste de cette façon:
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho (0, rect.size.width, rect.size.height, 0, 0, 1); // set to the drawing rectangle's size
glDisable(GL_DEPTH_TEST);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.375, 0.375, 0);
glClear(GL_COLOR_BUFFER_BIT);
// draw the actual point
glBegin(GL_POINTS);
glColor3f(1.0f, 1.0f, 1.0f); // white color
glVertex2f(x, y);
glEnd();