Results 1 to 1 of 1
  1. #1
    nap_patague is offline Member
    Join Date
    Mar 2011
    Location
    Bulacan, Philippines
    Posts
    23
    Rep Power
    0

    Default Help me Converting jar to jpg and jpg to jar

    hello to everyone

    im making this simple app that will convert jar file to jpeg picture and jpeg to jar file. i already created all necessary method but i do have problem with jpeg to jar.

    this my method to create a single pixel color of one character
    Java Code:
    private Color createPixel(int x) {
            Color c = null;
            int r = 0, g = 0, b = 0;
    
            int t = x / 255;
             if (t > 255) {
                b = 255;
                g = ((t % 255) * 255) + x % 255;
                if (g > 255) {
                    r = g % 255;
                    g = g / 255;
    
                } else {
                }
            } else {
                if (t < 255) {
                     r = x % 255;
                    g = x/255;
                }
            }
    return new Color(r, g, b);
    }
    and this is for converting rgb to char code
    Java Code:
    for (int y = 0; y < image.getHeight(); y++) {
                    for (int x = 0; x < image.getWidth(); x++) {
                        total = 0;
                        int c = image.getRGB(x, y);
                        r = (c & 0x00ff0000) >> 16;
                        g = (c & 0x0000ff00) >> 8;
                        b = c & 0x000000ff;
                        if (r == 255 && g == 255 && b == 255) {
                            System.out.println("end");
                            y = image.getHeight();
                            break;
                        } else {
    
                            if (r > 0) {
                                total += r;
                            }
                            if (g > 0) {
                                total += g * 255;
                            }
                            if (b == 255) {
                                total += 255 * 255;
                            } else {
                                total += b;
                            }
    but when i run my app. the character on the original is not equal to the converted character

    example is : is become ??

    the only problem is when the char code is greather than 60000 other char code are correct.

    hope someone can help me..
    Last edited by nap_patague; 03-20-2011 at 10:07 AM.

Similar Threads

  1. converting hex to dec -
    By Symbiot in forum New To Java
    Replies: 3
    Last Post: 05-27-2010, 02:56 PM
  2. need help converting
    By sr20guy in forum New To Java
    Replies: 16
    Last Post: 04-02-2010, 02:07 PM
  3. Converting to String
    By darek9576 in forum New To Java
    Replies: 1
    Last Post: 03-13-2010, 11:07 PM
  4. Converting URL to URI
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-26-2007, 11:15 AM
  5. help with converting to JApplet
    By Simmy in forum AWT / Swing
    Replies: 2
    Last Post: 08-09-2007, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •