We have created a Consolidated View (i.e. Image View with Annotation View) for displaying image and annotations together.
This consolidated view is displayed properly on Simulator, however a black layer is displayed on the Device.
Sir, here is the snippet code we used for creating the Consolidated View :
@interface IMGAnnotationView: UIView {
UIImageView *IMGView; /// It Contains the image which we have to display in our application
PaintingView *AnnotationView; // It contains the Annotation Part which we have to display with image.
UIActivityIndicatorView *progressInd;
......
......
.....
}
In the above code snippet the PaintingView is derived from UIView. It contain the support for the drawing annotations on the view using openGL functions.
-(UIImageView *)newPieceViewWithImageNamed

NSString *)imageName atPostion

CGPoint)centerPoint ModcaUIImg: (UIImage*)pModcaUIImg
{
if(![FullFileURL length])
FullFileURL=@"Icon.png";
UIImage *uimage ;
NSRange range = [FullFileURL rangeOfString:@"http:"];
if((range.location >=0)&&(range.length>0))
{
// it will create the image using the URL of the file which iPhone will support (i.e. BMP,JPEG ...)
NSURL *url = [NSURL URLWithString:FullFileURL];
NSData *data = [NSData dataWithContentsOfURL:url];
uimage = [UIImage imageWithData:data];
}
else
{
.......
......
.....
}
[self SetwindowSize:uimage.size ];
UIImageView *theView = [[UIImageView alloc] initWithImage:uimage];
// Set the center of the view.
centerPoint.x = ImgSize.width/2;
centerPoint.y = ImgSize.height/2;
theView.center = centerPoint;
// Set alpha so it is slightly transparent to allow seeing pieces move over each other.
theView.alpha = 1.0;
// Disable user interaction for this view. You must do this if you want to handle touches for more than one object at at time.
// You'll get events for the superview, and then dispatch them to the appropriate subview in the touch handling methods.
theView.userInteractionEnabled =YES;
theView.multipleTouchEnabled = YES;
return theView;
}
The above function will create the UIImageView with the specified FileURL . This IMGView displays the image at the background on the Image View.
- (id) initWithFrame

CGRect)frame
{
NSMutableArray* recordedPaths;
CGImageRef brushImage;
CGContextRef brushContext;
GLubyte *brushData;
size_t width, height;
if((self = [super initWithFrame:frame pixelFormat:GL_RGBA depthFormat:0 preserveBackbuffer:YES])) {
[self setCurrentContext];
// Create a texture from an image
// First create a UIImage object from the data in a image file, and then extract the Core Graphics image
brushImage = [UIImage imageNamed:@"Particle.png"].CGImage;
width = 16;///CGImageGetWidth(brushImage);
height = 16;///CGImageGetHeight(brushImage);
// Texture dimensions must be a power of 2. If you write an application that allows users to supply an image,
// you'll want to add code that checks the dimensions and takes appropriate action if they are not a power of 2.
// Make sure the image exists
if(brushImage) {
///if(0) {
// Allocate memory needed for the bitmap context
brushData = (GLubyte *) malloc(width * height * 4);
// Use the bitmatp creation function provided by the Core Graphics framework.
brushContext = CGBitmapContextCreate(brushData, width, width, 8, width * 4, CGImageGetColorSpace (brushImage), kCGImageAlphaPremultipliedLast);
// After you create the context, you can draw the image to the context.
CGContextDrawImage(brushContext, CGRectMake(0.0, 0.0, (CGFloat)width, (CGFloat)height), brushImage);
// You don't need the context at this point, so you need to release it to avoid memory leaks.
CGContextRelease(brushContext);
// Use OpenGL ES to generate a name for the texture.
glGenTextures(1, &brushTexture);
// Bind the texture name.
glBindTexture(GL_TEXTURE_2D, brushTexture);
// Specify a 2D texture image, providing the a pointer to the image data in memory
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, brushData);
// Release the image data; it's no longer needed
free(brushData);
// Set the texture parameters to use a minifying filter and a linear filer (weighted average)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_BLEND);
}
glDisable(GL_DITHER);
glMatrixMode(GL_PROJECTION);
glColor4f(1.0, 1.0,1.0, 1.0);
glOrthof(0, frame.size.width, 0, frame.size.height, -1, 1);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glEnableClientState(GL_VERTEX_ARRAY);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glEnable(GL_POINT_SPRITE_OES);
glTexEnvf(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);
glPointSize(width / kBrushScale);
[self erase];
}
self.userInteractionEnabled = NO;
self.alpha =0.0;
return self;
}
The above function creates the Annotation View with the specified image. This View displays the annotations on the Annotation View.
1) Annotations cannot be removed from the current annotation view without creating new annotation view.
Currently we have stored all the details of annotations in our data structures.
We delete the specified annotation from the data structures as well as the annotation view , then we create the new annotation view displaying all the annotation with the existing data structure.
We checked this thing in the sample code and the application behave very slowly while the above process(i.e. deletion of annotation) is applied many times.