Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 590751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:33:45+00:00 2026-05-13T15:33:45+00:00

Here are the details for what Picasa stores as a hash. It stores them

  • 0

Here are the details for what Picasa stores as a hash. It stores them like this:

faces=rect64(54391dc9b6a76c2b),4cd643f64b715489
[DSC_2289.jpg]
faces=rect64(1680000a5c26c82),76bc8d8d518750bc

Info on the web says this:

The number encased in rect64() is a 64-bit hexadecimal number.

  • Break that up into four 16-bit numbers.
  • Divide each by the maximum unsigned 16-bit number (65535) and you’ll have four numbers between 0 and 1.
  • The four numbers remaining give you relative coordinates for the face rectangle: (left, top, right, bottom).
  • If you want to end up with absolute coordinates, multiple the left and right by the image width and the top and bottom by the image height.

So my code to turn that into a RectangleF works just fine (only keeping relative coordinates):

    public static RectangleF GetRectangle(string hashstr)
    {
        UInt64 hash = UInt64.Parse(hashstr, System.Globalization.NumberStyles.HexNumber);
        byte[] bytes = BitConverter.GetBytes(hash);

        UInt16 l16 = BitConverter.ToUInt16(bytes, 6);
        UInt16 t16 = BitConverter.ToUInt16(bytes, 4);
        UInt16 r16 = BitConverter.ToUInt16(bytes, 2);
        UInt16 b16 = BitConverter.ToUInt16(bytes, 0);

        float left = l16 / 65535.0F;
        float top = t16 / 65535.0F;
        float right = r16 / 65535.0F;
        float bottom = b16 / 65535.0F;

        return new RectangleF(left, top, right - left, bottom - top);
    }

Now I have a RectangleF and I want to turn it back into the hash mentioned above. I can’t seem to figure this out. It looks like picasa uses 2 bytes including precision, however a float in C# is 8 bytes, and even BitConverter.ToSingle is 4 bytes.

Any help appreciated.

EDIT: Here is what I have right now

    public static string HashFromRectangle(RectangleCoordinates rect)
    {
        Console.WriteLine("{0} {1} {2} {3}", rect.Left, rect.Top, rect.Right, rect.Bottom);
        UInt16 left = Convert.ToUInt16((float)rect.Left * 65535.0F);
        UInt16 top = Convert.ToUInt16((float)rect.Top * 65535.0F);
        UInt16 right = Convert.ToUInt16((float)rect.Right * 65535.0F);
        UInt16 bottom = Convert.ToUInt16((float)rect.Bottom * 65535.0F);            

        byte[] lb = BitConverter.GetBytes(left);
        byte[] tb = BitConverter.GetBytes(top);
        byte[] rb = BitConverter.GetBytes(right);
        byte[] bb = BitConverter.GetBytes(bottom);

        byte[] barray = new byte[8];
        barray[0] = lb[0];
        barray[1] = lb[1];
        barray[2] = tb[0];
        barray[3] = tb[1];
        barray[4] = rb[0];
        barray[5] = rb[1];
        barray[6] = bb[0];
        barray[7] = bb[1];

        return BitConverter.ToString(barray).Replace("-", "").ToLower();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T15:33:45+00:00Added an answer on May 13, 2026 at 3:33 pm

    Your current code is swapping the bytes of each coordinate. This is because BitConverter gives you the bytes in little endian order (i.e. the first byte in the array is the least significant byte). Swapping around your assignments as follows makes decoding and re-encoding give back the original hash.

            barray[0] = lb[1];
            barray[1] = lb[0];
            barray[2] = tb[1];
            barray[3] = tb[0];
            barray[4] = rb[1];
            barray[5] = rb[0];
            barray[6] = bb[1];
            barray[7] = bb[0];
    

    That said, I think it’s clearer to do the conversion using simple multiplies and adds. You can do a similar thing with the decoding of the hash string if you read it in as a single ulong and subtract/divide. e.g. for the encoding:

        public static ushort ToUShort(double coordinate)
        {
            double ratio = Math.Max(0, Math.Min(Math.Round(coordinate * 65535), 65535));
            return (ushort)ratio;
        }
    
        public static string HashFromRectangle(Rect rect)
        {
            ulong left = ToUShort(rect.Left);
            ulong top = ToUShort(rect.Top);
            ulong right = ToUShort(rect.Right);
            ulong bottom = ToUShort(rect.Bottom);
    
            ulong hash = (((left * 65536) + top) * 65536 + right) * 65536 + bottom;
            return hash.ToString("x");
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a theoretical question, so expect that many details here are not computable
Im using emgu in my project. I get this exceptit: Here the details of
I am using hibernate 3.2 with struts 1.2 framework here is the details of
I'm creating a simple questions DB, here are some details to start: 1st off,
OK. So, here's some details on my situation : I've got a brand-new iPhone
Here is the problem details: 1) I want to create dynamic (ip based) download
Here's some LINQ to select all order details. It creates a join with the
Here is the model we are using to store the CC details how secure
Here is my code.. string attachment = attachment; filename=Call-Details-Report- + startDate.SelectedDate.Value.ToString(MM-dd-yyyy) + .csv; Response.Clear();
I am having trouble running Purify on Suse Linux. Here are the version details:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.