I want to check whether the line exist between two points are not? but the line is in image... Can we read the image from one point to another point in objective c?
Here you can find all the real time issues we faced while developing iPhone, android applications
Saturday, 5 January 2013
How to read Color of image in particulr pixel?
- (UIColor *)colorAtPixel:(CGPoint)point {
// Cancel if point is outside image coordinates
if (!CGRectContainsPoint(CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), point)) {
return nil;
}
// Create a 1x1 pixel byte array and bitmap context to draw the pixel into.
// Reference: http://stackoverflow.com/questions/1042830/retrieving-a-pixel-alpha-value-for-a-uiimage
NSInteger pointX = trunc(point.x);
NSInteger pointY = trunc(point.y);
CGImageRef cgImage = self.CGImage;
NSUInteger width = CGImageGetWidth(cgImage);
NSUInteger height = CGImageGetHeight(cgImage);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
int bytesPerPixel = 4;
int bytesPerRow = bytesPerPixel * 1;
NSUInteger bitsPerComponent = 8;
unsigned char pixelData[4] = { 0, 0, 0, 0 };
CGContextRef context = CGBitmapContextCreate(pixelData,
1,
1,
bitsPerComponent,
bytesPerRow,
colorSpace,
kCGImageAlphaPremultipliedLast | kCGBitmapByteOrder32Big);
CGColorSpaceRelease(colorSpace);
CGContextSetBlendMode(context, kCGBlendModeCopy);
// Draw the pixel we are interested in onto the bitmap context
CGContextTranslateCTM(context, -pointX, -pointY);
CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, (CGFloat)width, (CGFloat)height), cgImage);
CGContextRelease(context);
// Convert color values [0..255] to floats [0.0..1.0]
CGFloat red = (CGFloat)pixelData[0] / 255.0f;
CGFloat green = (CGFloat)pixelData[1] / 255.0f;
CGFloat blue = (CGFloat)pixelData[2] / 255.0f;
CGFloat alpha = (CGFloat)pixelData[3] / 255.0f;
return [UIColor colorWithRed:red green:green blue:blue alpha:alpha];
}
How to access session variables set by an external script in joomla site
How to access session variables set
by an external script ??
Solution: Replace session_start(); in your external script with
---------------------------------------------------------------------------------------
define(
'_JEXEC', 1 );
define(
'JPATH_BASE', realpath(dirname(__FILE__).'/../..' ));
define(
'DS', DIRECTORY_SEPARATOR );
require_once
( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once
( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe
=& JFactory::getApplication('site');
$mainframe->initialise();
--------------------------------------------------------------------------
Be sure to change JPATH_BASE to suit your directory structure.
Replace the $_SESSION[ 'name' ] = "value"; in your external script with
-------------------------------------------------------------------------
$session =& JFactory::getSession();
$session->set('name', "value");
------------------------------------------------------------------------
Now you can retrieve this session variable using:
-----------------------------------------------------------------------
$session =& JFactory::getSession();
echo $session->get('name');
--------------------------------------------------
Change the Tomcat Port Number
Question: How to change tomcat port number what ever number we want not only 8080?
Answer:
In eclipse bottom
1.Go to "servers" tab under that Right click on
"Tomcat v6.0 server at localhost".
2.Here
click on "open" .
3.After that "Tomcat server localhost" window will
open.In that click on “Ports”.
Here click on "Http/1.1---8080" .In that 8080 place we can edit that number.
4. After starting the server,in browser we can type like
this
http://localhost:urnumber.
Example:http://localhost:555
GC overhead limit exceeded in Eclipse
Error:- GC overhead limit exceeded in Eclipse
When it occur;-
Eclipse will throw "GC overhead limit exceeded in eclipse" error when it runs on the out of memory.And one more thing is when you want to run the eclipse on 64bit machine it requires more space .
To fix this problem we need to allocate more memory for eclipse.
How to Fix:
Go to the your root folder of Eclipse. (where you can installed in your system) .
Open that folder.
In that folder find the eclipse.ini file.
The file looks like below
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20120522-1813
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Dhelp.lucene.tokenizer=standard
-Xms40m
-Xmx1384m
Chang the following lines as
-Xms40m AS -Xms512m
-Xmx384m AS -Xmx1024m
Restart the eclipse.problem will resolved.
----------------------------------------*Hope Help Full*------------------------------------------------
Friday, 4 January 2013
"Reverse geocoding to find an well formatted address??"
Reverse geocoding to find an formatted address ??
"Reverse geo address is nothing but simply getting the fully formatted
address (like street number, street name, city, state and country) by passing latitude
and longitude to Geocoding API. "
How to send a request to Geocoding API service for getting the formatted address ??
The following link gives an idea about reverse geocoding XML service to
get an address.
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false
Complete reference link – https://developers.google.com/maps/documentation/geocoding/
Geolocation Tracing
Geolocation Tracing
How to get the latitude and longitude of current geo position using Android while the user is moving
Good Afternoon,
I am working on Google maps app in that i need to track the Geo location of the user/mobile while moving. This code solved my problem smoothly. Try this it may help you.
I am working on Google maps app in that i need to track the Geo location of the user/mobile while moving. This code solved my problem smoothly. Try this it may help you.
// The minimum distance to change Updates in meters
private static final long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters
// The minimum time between updates in milliseconds
private static final long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute
// Declaring a Location Manager
protected LocationManager locationManager;
public Location getLocation() {
try {
locationManager = (LocationManager) mContext
.getSystemService(LOCATION_SERVICE);
// getting GPS status
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);
// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
if (!isGPSEnabled && !isNetworkEnabled) {
// no network provider is enabled
} else {
this.canGetLocation = true;
if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("Network", "Network");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (location == null) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
Log.d("GPS Enabled", "GPS Enabled");
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return location;
}
Subscribe to:
Posts (Atom)


