Advertise Books Events Forum News Social Networking Support Us

sdkIQ for iPhone
($4.99)

Shape Up
($0.99)

Your First iPhone App
($1.99)

Graves Robber
($1.99)

African Adventure
($0.99)

iTazer
($0.99)

ArtStudio
($3.99)

Pigs Vs Wolves
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-28-2009, 11:35 AM   #1 (permalink)
New Member
 
Join Date: May 2009
Posts: 2
Default ISSUE of Editing in Image with UIImageView

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 *)newPieceViewWithImageNamedNSString *)imageName atPostionCGPoint)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) initWithFrameCGRect)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.
mstechnology is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Enter the iPhone App Challenge!  Win $500!
» Advertisements
» Stats
Members: 23,591
Threads: 38,347
Posts: 168,505
Top Poster: smasher (2,539)
Welcome to our newest member, gotaway
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0