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; | 423 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
Noel Gordon
2014/09/12 15:23:42
nit - space before this line.
| |
424 base64Encode(encodedImage, base64Data); | |
425 | |
426 return "data:" + mimeType + ";base64," + base64Data; | |
427 } | 424 } |
428 | 425 |
429 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy pe, const double* quality) | 426 String ImageDataToDataURL(const ImageDataBuffer& imageData, const String& mimeTy pe, const double* quality) |
430 { | 427 { |
431 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); | 428 ASSERT(MIMETypeRegistry::isSupportedImageMIMETypeForEncoding(mimeType)); |
432 | 429 |
433 Vector<char> encodedImage; | 430 Vector<char> encodedImage; |
434 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) | 431 if (!encodeImage(imageData, mimeType, quality, &encodedImage)) |
435 return "data:,"; | 432 return "data:,"; |
436 | 433 |
437 Vector<char> base64Data; | 434 return "data:" + mimeType + ";base64," + base64Encode(encodedImage); |
438 base64Encode(encodedImage, base64Data); | |
439 | |
440 return "data:" + mimeType + ";base64," + base64Data; | |
441 } | 435 } |
442 | 436 |
443 } // namespace blink | 437 } // namespace blink |
OLD | NEW |