Mercurial > projects > dwt2
comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/internal/image/PngDeflater.d @ 120:536e43f63c81
Comprehensive update for Win32/Linux32 dmd-2.053/dmd-1.068+Tango-r5661
===D2===
* added [Try]Immutable/Const/Shared templates to work with differenses in D1/D2 instead of version statements
used these templates to work with strict type storage rules of dmd-2.053
* com.ibm.icu now also compilable with D2, but not tested yet
* small fixes
Snippet288 - shared data is in TLS
===Phobos===
* fixed critical bugs in Phobos implemention
completely incorrect segfault prone fromStringz (Linux's port ruthless killer)
terrible, incorrect StringBuffer realization (StyledText killer)
* fixed small bugs as well
Snippet72 - misprint in the snippet
* implemented missed functionality for Phobos
ByteArrayOutputStream implemented (image loading available)
formatting correctly works for all DWT's cases
As a result, folowing snippets now works with Phobos (Snippet### - what is fixed):
Snippet24, 42, 111, 115, 130, 235, 276 - bad string formatting
Snippet48, 282 - crash on image loading
Snippet163, 189, 211, 213, 217, 218, 222 - crash on copy/cut in StyledText
Snippet244 - hang-up
===Tango===
* few changes for the latest Tango trunc-r5661
* few small performance improvments
===General===
* implMissing-s for only one version changed to implMissingInTango/InPhobos
* incorrect calls to Format in toString-s fixed
* fixed loading \uXXXX characters in ResourceBundle
* added good UTF-8 support for StyledText, TextLayout (Win32) and friends
UTF functions revised and tested. It is now in java.nonstandard.*Utf modules
StyledText and TextLayout (Win32) modules revised for UTF-8 support
* removed small diferences in most identical files in *.swt.* folders
*.swt.internal.image, *.swt.events and *.swt.custom are identical in Win32/Linux32
now 179 of 576 (~31%) files in *.swt.* folders are fully identical
* Win32: snippets now have right subsystem, pretty icons and native system style controls
* small fixes in snippets
Snippet44 - it's not Snippet44
Snippet212 - functions work with different images and offsets arrays
Win32: Snippet282 - crash on close if the button has an image
Snippet293 - setGrayed is commented
and others
Win32: As a result, folowing snippets now works
Snippet68 - color doesn't change
Snippet163, 189, 211, 213, 217, 218, 222 - UTF-8 issues (see above)
Snippet193 - no tabel headers
author | Denis Shelomovskij <verylonglogin.reg@gmail.com> |
---|---|
date | Sat, 09 Jul 2011 15:50:20 +0300 |
parents | 0ecb2b338560 |
children |
comparison
equal
deleted
inserted
replaced
119:d00e8db0a568 | 120:536e43f63c81 |
---|---|
11 * Frank Benoit <benoit@tionex.de> | 11 * Frank Benoit <benoit@tionex.de> |
12 *******************************************************************************/ | 12 *******************************************************************************/ |
13 module org.eclipse.swt.internal.image.PngDeflater; | 13 module org.eclipse.swt.internal.image.PngDeflater; |
14 | 14 |
15 import java.io.ByteArrayOutputStream; | 15 import java.io.ByteArrayOutputStream; |
16 import java.lang.all; | |
16 | 17 |
17 public class PngDeflater { | 18 public class PngDeflater { |
18 | 19 |
19 static const int BASE = 65521; | 20 static const int BASE = 65521; |
20 static const int WINDOW = 32768; | 21 static const int WINDOW = 32768; |
21 static const int MIN_LENGTH = 3; | 22 static const int MIN_LENGTH = 3; |
22 static const int MAX_MATCHES = 32; | 23 static const int MAX_MATCHES = 32; |
23 static const int HASH = 8209; | 24 static const int HASH = 8209; |
24 | 25 |
25 byte[] istr; | 26 TryConst!(byte)[] istr; |
26 int inLength; | 27 int inLength; |
27 | 28 |
28 ByteArrayOutputStream bytes; | 29 ByteArrayOutputStream bytes; |
29 | 30 |
30 int adler32 = 1; | 31 int adler32 = 1; |
118 | 119 |
119 } | 120 } |
120 | 121 |
121 } | 122 } |
122 | 123 |
123 static /*const*/ Code lengthCodes[]; | 124 static TryConst!(Code[]) lengthCodes; |
124 static /*const*/ Code distanceCodes[]; | 125 static TryConst!(Code[]) distanceCodes; |
125 | 126 |
126 static this() { | 127 static this() { |
127 lengthCodes = [ | 128 lengthCodes = [ |
128 new Code(257, 0, 3, 3), | 129 new Code(257, 0, 3, 3), |
129 new Code(258, 0, 4, 4), | 130 new Code(258, 0, 4, 4), |
217 high = (low + high) % BASE; | 218 high = (low + high) % BASE; |
218 adler32 = (high << 16) | low; | 219 adler32 = (high << 16) | low; |
219 | 220 |
220 } | 221 } |
221 | 222 |
222 int hash(byte[] bytes) { | 223 int hash(in byte[] bytes) { |
223 | 224 |
224 int hash = ((bytes[0] & 0xff) << 24 | (bytes[1] & 0xff) << 16 | (bytes[2] & 0xff) << 8) % HASH; | 225 int hash = ((bytes[0] & 0xff) << 24 | (bytes[1] & 0xff) << 16 | (bytes[2] & 0xff) << 8) % HASH; |
225 if (hash < 0) { | 226 if (hash < 0) { |
226 hash = hash + HASH; | 227 hash = hash + HASH; |
227 } | 228 } |
266 writeBits(1 + 2 * mirrorBytes[0x90 - 144 + i], 9); | 267 writeBits(1 + 2 * mirrorBytes[0x90 - 144 + i], 9); |
267 } | 268 } |
268 | 269 |
269 } | 270 } |
270 | 271 |
271 Code findCode(int value, Code[] codes) { | 272 TryConst!(Code) findCode(int value, in Code[] codes) { |
272 | 273 |
273 int i, j, k; | 274 int i, j, k; |
274 | 275 |
275 i = -1; | 276 i = -1; |
276 j = codes.length; | 277 j = codes.length; |
289 | 290 |
290 } | 291 } |
291 | 292 |
292 void outputMatch(int length, int distance) { | 293 void outputMatch(int length, int distance) { |
293 | 294 |
294 Code d, l; | |
295 int thisLength; | 295 int thisLength; |
296 | 296 |
297 while (length > 0) { | 297 while (length > 0) { |
298 | 298 |
299 // we can transmit matches of lengths 3 through 258 inclusive | 299 // we can transmit matches of lengths 3 through 258 inclusive |
311 } | 311 } |
312 | 312 |
313 length = length - thisLength; | 313 length = length - thisLength; |
314 | 314 |
315 // find length code | 315 // find length code |
316 l = findCode(thisLength, lengthCodes); | 316 auto l = findCode(thisLength, lengthCodes); |
317 | 317 |
318 // transmit the length code | 318 // transmit the length code |
319 // 256 through 279 are 7 bits long starting at 0000000 | 319 // 256 through 279 are 7 bits long starting at 0000000 |
320 // 280 through 287 are 8 bits long starting at 11000000 | 320 // 280 through 287 are 8 bits long starting at 11000000 |
321 if (l.code <= 279) { | 321 if (l.code <= 279) { |
329 if (l.extraBits !is 0) { | 329 if (l.extraBits !is 0) { |
330 writeBits(thisLength - l.min, l.extraBits); | 330 writeBits(thisLength - l.min, l.extraBits); |
331 } | 331 } |
332 | 332 |
333 // find distance code | 333 // find distance code |
334 d = findCode(distance, distanceCodes); | 334 auto d = findCode(distance, distanceCodes); |
335 | 335 |
336 // transmit the distance code | 336 // transmit the distance code |
337 // 5 bits long starting at 00000 | 337 // 5 bits long starting at 00000 |
338 writeBits(mirrorBytes[d.code * 8], 5); | 338 writeBits(mirrorBytes[d.code * 8], 5); |
339 | 339 |
591 | 591 |
592 } | 592 } |
593 | 593 |
594 } | 594 } |
595 | 595 |
596 public byte[] deflate(byte[] input) { | 596 public byte[] deflate(in byte[] input) { |
597 | 597 |
598 istr = input; | 598 istr = input; |
599 inLength = input.length; | 599 inLength = input.length; |
600 | 600 |
601 // write zlib header | 601 // write zlib header |