Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($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 10-12-2010, 12:52 PM   #26 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 459
NewiPhoneDeveloper is on a distinguished road
Default

Quote:
Originally Posted by blacky View Post
@NewiPhoneDeveloper

I am working on an app that uses some part of GLPaint code to paint over an image.

I am new to iphone development and for now am working directly on the GLPaint app to show image.

I do not have any UIImageView in the background I tried the your snippet but the screen is still blank (white). I think the init method clears everything to prepare for painting. I am not sure how to bring the image for painting.

Please throw some light on this.

Thanks in advance.
So, you want to paint over some image, right? The easiest way to achieve this, is to simply set the "opaque" value of your eaglLayer to NO. Usually it's inside a method, named "- (BOOL) _createSurface". Look for the following line:
Code:
eaglLayer.opaque = YES;
and set it to
Code:
eaglLayer.opaque = NO;
Now your eaglLayer should be transparent and reveal whatever view you put behind it. This way you don't actually have to put the image, you want to paint over, into your eaglView. Instead you can simply have it inside some UIView, you add as subView behind your eaglView. Makes sense?

In case I didn't get you right on this one, please post some code. Thanks.
__________________
Websites:
Friendlydeveloper - Coding Blog
Codingsessions - Live iOS Training

iPhone Apps:
TextPal - Powerful group messaging,
icePhone

Find me on LinkedIn
NewiPhoneDeveloper is offline   Reply With Quote
Old 10-12-2010, 09:15 PM   #27 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 8
blacky is on a distinguished road
Default

Quote:
Originally Posted by NewiPhoneDeveloper View Post
So, you want to paint over some image, right? The easiest way to achieve this, is to simply set the "opaque" value of your eaglLayer to NO. Usually it's inside a method, named "- (BOOL) _createSurface". Look for the following line:
Code:
eaglLayer.opaque = YES;
and set it to
Code:
eaglLayer.opaque = NO;
Now your eaglLayer should be transparent and reveal whatever view you put behind it. This way you don't actually have to put the image, you want to paint over, into your eaglView. Instead you can simply have it inside some UIView, you add as subView behind your eaglView. Makes sense?

In case I didn't get you right on this one, please post some code. Thanks.

Hi,

Given below is the PaintingView.m code in GLPaint where eaglLayer set transparent in the PaintingView.initWithCode(). I get a white screen showing it is transparent but the image pattern is not set in the window.

Code:
......

 if ((self = [super initWithCoder:coder])) {
		//[imageView release];
		CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;


		//****************** eaglLayer set to transparent so that the image below the view is made visible
		eaglLayer.opaque = NO;
		
		//****************** The image is rendered as color pattern and set in the window behind .... There is no need for UIImageView
		//********* Having a UIImageView brings up an image but did not help in painting over image
		UIImage *patternImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Image" ofType:@"png"]];
		[self.window setBackgroundColor:[UIColor colorWithPatternImage:patternImage]];


		// In this application, we want to retain the EAGLDrawable contents after a call to presentRenderbuffer.
		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
										[NSNumber numberWithBool:YES], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
		
		context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
		
		if (!context || ![EAGLContext setCurrentContext:context]) {
			[self release];
			return nil;
		}

		
		// 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;
		
		NSLog(@"PaintingView -- Get the width and height of the image");
		// Get the width and height of the image
		width = CGImageGetWidth(brushImage);
		height = CGImageGetHeight(brushImage);
......
I tried to learn how GLImageProcessing app brings up the butterfly image in the eaglLayer so that I could save the image with the painted pattern, but got complicated.

Please point out the mistake am doing here.

Thank you.
blacky is offline   Reply With Quote
Old 10-12-2010, 10:07 PM   #28 (permalink)
Registered Member
 
Join Date: Jul 2008
Posts: 459
NewiPhoneDeveloper is on a distinguished road
Default

Quote:
Originally Posted by blacky View Post
Hi,

Given below is the PaintingView.m code in GLPaint where eaglLayer set transparent in the PaintingView.initWithCode(). I get a white screen showing it is transparent but the image pattern is not set in the window.

Code:
......

 if ((self = [super initWithCoder:coder])) {
		//[imageView release];
		CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;


		//****************** eaglLayer set to transparent so that the image below the view is made visible
		eaglLayer.opaque = NO;
		
		//****************** The image is rendered as color pattern and set in the window behind .... There is no need for UIImageView
		//********* Having a UIImageView brings up an image but did not help in painting over image
		UIImage *patternImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Image" ofType:@"png"]];
		[self.window setBackgroundColor:[UIColor colorWithPatternImage:patternImage]];


		// In this application, we want to retain the EAGLDrawable contents after a call to presentRenderbuffer.
		eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
										[NSNumber numberWithBool:YES], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
		
		context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
		
		if (!context || ![EAGLContext setCurrentContext:context]) {
			[self release];
			return nil;
		}

		
		// 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;
		
		NSLog(@"PaintingView -- Get the width and height of the image");
		// Get the width and height of the image
		width = CGImageGetWidth(brushImage);
		height = CGImageGetHeight(brushImage);
......
I tried to learn how GLImageProcessing app brings up the butterfly image in the eaglLayer so that I could save the image with the painted pattern, but got complicated.

Please point out the mistake am doing here.

Thank you.
Hi,

I just grabbed the latest GLPaint demo and had to do 2 things, in order to get this to work:

1) add your background image inside the AppController.m file, like
Code:
- (void) applicationDidFinishLaunching:(UIApplication*)application {
    //I'm using a UIImageView, because setting the image as pattern image does no longer seem to work. It used to in older versions of GLPaint.
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameOfImage.png"]];
	[self.window insertSubview:imageView atIndex:0];
    
    [backgroundImageView release];
}
2) Inside the initWithCoder method add the following line:
Code:
self.backgroundColor = [UIColor clearColor];
Hope, this information was helpful to you.
__________________
Websites:
Friendlydeveloper - Coding Blog
Codingsessions - Live iOS Training

iPhone Apps:
TextPal - Powerful group messaging,
icePhone

Find me on LinkedIn
NewiPhoneDeveloper is offline   Reply With Quote
Old 10-12-2010, 10:48 PM   #29 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 8
blacky is on a distinguished road
Default Thank you so much!!!

Quote:
Originally Posted by NewiPhoneDeveloper View Post
Hi,

I just grabbed the latest GLPaint demo and had to do 2 things, in order to get this to work:

1) add your background image inside the AppController.m file, like
Code:
- (void) applicationDidFinishLaunching:(UIApplication*)application {
    //I'm using a UIImageView, because setting the image as pattern image does no longer seem to work. It used to in older versions of GLPaint.
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameOfImage.png"]];
	[self.window insertSubview:imageView atIndex:0];
    
    [backgroundImageView release];
}
2) Inside the initWithCoder method add the following line:
Code:
self.backgroundColor = [UIColor clearColor];
Hope, this information was helpful to you.
Hey,

I tried it with the current GLPaint demo code, It worked as expected. I'll integrate the code with other components (color picker, save and clear tab bars) and post questions if I get into trouble again.

Thanks a lot for your help I really appreciate it.
blacky is offline   Reply With Quote
Old 10-15-2010, 03:39 AM   #30 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 8
blacky is on a distinguished road
Default Need help on using loading PaintingView(of GLPaint) without PaintingWindow

@NewiPhoneDeveloper

The paint over a image is working now. I could save just the painted pattern, but its okay for now. Facing another problem.

The GLPaint demo loads the PaintingView from the PaintingWindow. But in my app, the paint view comes as 3rd step. I am trying to load the paintingView from the 2nd UIViewController class (as I did for loading 2nd from 1st).

I use the following code to load 2nd UIViewController from the 1st UIViewController.

FirstViewController:
Code:
-(IBAction) goToSecondView
{
	[self presentModalViewController:secondViewController animated:YES];
}
I actually created a paintViewController with an xib and placed the PaintingView and my other toolbar buttons over the view generated during xib creation (instead of UIWindow). And used the following code to load the paintingViewController.

secondViewController:

Code:
[self presentModalViewController:paintingViewController animated:YES];

... I am not using the segmented controls created programatically in AppController.m -> applicationDidFinishLaunching();
Attached Images
File Type: jpg Screen shot 2010-10-15 at 4.34.08 AM.jpg (20.3 KB, 2 views)
blacky is offline   Reply With Quote
Old 10-15-2010, 02:43 PM   #31 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 8
blacky is on a distinguished road
Default Issue Resolved

@NewiPhoneDeveloper

The issue is resolved now. The problem was with the compilers. The painting view was compiled as Objective C and the other views I used some C++ classes which made them compiled into Objective C++. So ran into conflicts during integration. I was able to find the c alternative for those views and it works fine now.

Thank you.
blacky is offline   Reply With Quote
Old 03-17-2011, 01:18 AM   #32 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 3
sanjeevrao.lade is on a distinguished road
Default Many thanks.

Quote:
Originally Posted by NewiPhoneDeveloper View Post
Hi,

I just grabbed the latest GLPaint demo and had to do 2 things, in order to get this to work:

1) add your background image inside the AppController.m file, like
Code:
- (void) applicationDidFinishLaunching:(UIApplication*)application {
    //I'm using a UIImageView, because setting the image as pattern image does no longer seem to work. It used to in older versions of GLPaint.
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameOfImage.png"]];
	[self.window insertSubview:imageView atIndex:0];
    
    [backgroundImageView release];
}
2) Inside the initWithCoder method add the following line:
Code:
self.backgroundColor = [UIColor clearColor];
Hope, this information was helpful to you.

Hello,

Your brilliant idea saved my life (i can say). It is really great thing for me.

If possible can you suggest me, how to do undo,redo in GLPaint.
sanjeevrao.lade is offline   Reply With Quote
Old 03-28-2011, 07:46 AM   #33 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 3
sanjeevrao.lade is on a distinguished road
Default GLPaint UNDO - REDO functionality HELP

Quote:
Originally Posted by NewiPhoneDeveloper View Post
Hi,

I just grabbed the latest GLPaint demo and had to do 2 things, in order to get this to work:

1) add your background image inside the AppController.m file, like
Code:
- (void) applicationDidFinishLaunching:(UIApplication*)application {
    //I'm using a UIImageView, because setting the image as pattern image does no longer seem to work. It used to in older versions of GLPaint.
    UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"nameOfImage.png"]];
	[self.window insertSubview:imageView atIndex:0];
    
    [backgroundImageView release];
}
2) Inside the initWithCoder method add the following line:
Code:
self.backgroundColor = [UIColor clearColor];
Hope, this information was helpful to you.
Background setting with image View worked as a charm for me, i have another issue,please help out in UNDO , REDO in GLPaint based app
sanjeevrao.lade 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



» Advertisements
» Online Users: 341
6 members and 335 guests
givensur, ipodphone, jbro, mer10, mtl_tech_guy, yomo710
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,113
Posts: 402,881
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:10 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0