Hi Brad.
How are you? I am using your GPUImage library in many projects and Thank you.
Now I am using GPUImageCrosshairGenerator in the video filtering app.
I can see crosshairs in the camera and it's working well.
I am just wondering if I replace the crosshair with UIImage. I tried so many times to replace the crosshairs but it won't working.
Hi Brad. How are you? I am using your GPUImage library in many projects and Thank you. Now I am using GPUImageCrosshairGenerator in the video filtering app. I can see crosshairs in the camera and it's working well.
I am just wondering if I replace the crosshair with UIImage. I tried so many times to replace the crosshairs but it won't working.
UIImage sparkleImage; GLuint sparkleName; GLubyte sparkleData;
sparkleName = [self setupTexture:@"sparkle"];
(GLuint)setupTexture:(NSString *)textureName { sparkleImage = [UIImage imageNamed:textureName]; CGImageRef sparkleImageRef = sparkleImage.CGImage; if (!sparkleImage) { NSLog(@"Failed to load image %@", textureName); }
size_t width = CGImageGetWidth(sparkleImageRef); size_t height = CGImageGetHeight(sparkleImageRef);
sparkleData = (GLubyte ) calloc(widthheight*4, sizeof(GLubyte));
CGContextRef spriteContext = CGBitmapContextCreate(sparkleData, width, height, 8, width*4, CGImageGetColorSpace(sparkleImageRef), kCGImageAlphaPremultipliedLast);
CGContextDrawImage(spriteContext, CGRectMake(0, 0, width, height), sparkleImageRef); CGContextRelease(spriteContext);
GLuint texName; glGenTextures(1, &texName); glBindTexture(GL_TEXTURE_2D, texName);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (int)width, (int)height, 0, GL_RGBA, GL_UNSIGNED_BYTE, sparkleData);
return texName; }
So I got the Texture info. And then I tried to change following method to replace the crosshairs with sparkleImage but it won't working.
(void)renderCrosshairsFromArray:(GLfloat *)crosshairCoordinates count:(NSUInteger)numberOfCrosshairs frameTime:(CMTime)frameTime; { if (self.preventRendering) { return; }
runSynchronouslyOnVideoProcessingQueue(^{ [GPUImageContext setActiveShaderProgram:filterProgram];
if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
else
endif
}
Can you please help me to edit the above method? I will appreciate for your help.
Kind Regards. Hua.