سؤال

أنا أبحث عن تنفيذ لطيفة وفعالة لخوارزمية رسم خط شياو وو المضادة للتعيس في ج، هل لدى أي شخص هذا الرمز يمكنهم مشاركتها معي؟

شكرا

هل كانت مفيدة؟

المحلول

ويكيبيديا لديه كود مزيف.

جوجل لديه العديد من الأمثلة مثل هذا أو هذا. وبعد وسؤالك ذكرني هذه المقالة الجميلة الفادحة.

تحرير: حان الوقت لاكتشاف موقع هوغو هيلياس إذا كنت لا تعرف ذلك بالفعل.

نصائح أخرى

أتساءل عما إذا كان التنفيذ هنا هو الصحيح، لأنه في

ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY;
      /* Draw all pixels other than the first and last */
while (--DeltaY) {
         ErrorAccTemp = ErrorAcc;   /* remember current accumulated error */
         ErrorAcc += ErrorAdj;      /* calculate error for next pixel */
         if (ErrorAcc <= ErrorAccTemp) {
            /* The error accumulator turned over, so advance the X coord */
            X0 += XDir;
         }
         Y0++; /* Y-major, so always advance Y */
         /* The IntensityBits most significant bits of ErrorAcc give us the
            intensity weighting for this pixel, and the complement of the
            weighting for the paired pixel */
         Weighting = ErrorAcc >> IntensityShift;
         DrawPixel(pDC,X0, Y0, BaseColor + Weighting);
         DrawPixel(pDC,X0 + XDir, Y0,
               BaseColor + (Weighting ^ WeightingComplementMask));
      }

شرط if (ErrorAcc <= ErrorAccTemp) هو دائما خطأ.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top