| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
| 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 3 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
| 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 4 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 5 * | 5 * |
| 6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
| 7 * modification, are permitted provided that the following conditions are | 7 * modification, are permitted provided that the following conditions are |
| 8 * met: | 8 * met: |
| 9 * | 9 * |
| 10 * * Redistributions of source code must retain the above copyright | 10 * * Redistributions of source code must retain the above copyright |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 return true; | 413 return true; |
| 414 } | 414 } |
| 415 | 415 |
| 416 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
st | 416 String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
st |
| 417 { | 417 { |
| 418 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 418 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 419 | 419 |
| 420 Vector<char> encodedImage; | 420 Vector<char> encodedImage; |
| 421 if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality
, &encodedImage)) | 421 if (!isSurfaceValid() || !encodeImage(m_surface->bitmap(), mimeType, quality
, &encodedImage)) |
| 422 return "data:,"; | 422 return "data:,"; |
| 423 Vector<char> base64Data; | |
| 424 base64Encode(encodedImage, base64Data); | |
| 425 | 423 |
| 426 return "data:" + mimeType + ";base64," + base64Data; | 424 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 427 } | 425 } |
| 428 | 426 |
| 429 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy
pe, const double* quality) | 427 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy
pe, const double* quality) |
| 430 { | 428 { |
| 431 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 429 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
| 432 | 430 |
| 433 Vector<char> encodedImage; | 431 Vector<char> encodedImage; |
| 434 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 432 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
| 435 return "data:,"; | 433 return "data:,"; |
| 436 | 434 |
| 437 Vector<char> base64Data; | 435 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
| 438 base64Encode(encodedImage, base64Data); | |
| 439 | |
| 440 return "data:" + mimeType + ";base64," + base64Data; | |
| 441 } | 436 } |
| 442 | 437 |
| 443 } // namespace blink | 438 } // namespace blink |
| OLD | NEW |