- return Palette->GetRGB(GetIndex(x, y), r, g, b);
-/* PALETTEENTRY entry;
- ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
- *r = entry.peRed;
- *g = entry.peGreen;
- *b = entry.peBlue; */
+ return Palette->GetRGB(GetIndex(x, y), r, g, b);
+/* PALETTEENTRY entry;
+ ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry);
+ *r = entry.peRed;
+ *g = entry.peGreen;
+ *b = entry.peBlue; */
// tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
// is a memory dc that must have a bitmap selected into it)
HDC dc2 = GetDC(NULL);
HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
ReleaseDC(NULL, dc2);
// tmpBitmap is a dummy, to satisfy ::CreateCompatibleDC (it
// is a memory dc that must have a bitmap selected into it)
HDC dc2 = GetDC(NULL);
HBITMAP tmpBitmap = ::CreateCompatibleBitmap(dc2, GetWidth(), GetHeight());
ReleaseDC(NULL, dc2);
- HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
- CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
+ HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi,
+ CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS);
logPal->palVersion = 0x300;
logPal->palNumEntries = count;
::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
logPal->palVersion = 0x300;
logPal->palNumEntries = count;
::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry);
- wxPNGReaderIter iter(this);
-
- /* open the file */
- fp = fopen(filename, "rb");
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete(png_ptr);
- return FALSE;
- }
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
- fclose(fp);
- delete(png_ptr);
- delete(info_ptr);
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
+ wxPNGReaderIter iter(this);
+
+ /* open the file */
+ fp = fopen(wxConvFile.cWX2MB(filename), "rb");
+ if (!fp)
+ return FALSE;
+
+ /* allocate the necessary structures */
+ png_ptr = new (png_struct);
+ if (!png_ptr)
+ {
+ fclose(fp);
+ return FALSE;
+ }
+
+ info_ptr = new (png_info);
+ if (!info_ptr)
+ {
+ fclose(fp);
+ delete(png_ptr);
+ return FALSE;
+ }
+ /* set error handling */
+ if (setjmp(png_ptr->jmpbuf))
+ {
+ png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+ fclose(fp);
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* If we get here, we had a problem reading the file */
+ return FALSE;
+ }
- int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
- // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
-// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
-
- byte *row_pointers = new byte[row_stride];
-
- /* turn on interlace handling */
- if (info_ptr->interlace_type)
- number_passes = png_set_interlace_handling(png_ptr);
- else
- number_passes = 1;
-// printf("NP = %d ", number_passes);
-
- for (int pass=0; pass< number_passes; pass++) {
- iter.upset();
- int y=0;
- do {
-// (unsigned char *)iter.GetRow();
- if (info_ptr->interlace_type) {
- if (pass>0)
- iter.GetRow(row_pointers, row_stride);
- png_read_row(png_ptr, row_pointers, NULL);
- }
- else
- png_read_row(png_ptr, row_pointers, NULL);
-
- iter.SetRow(row_pointers, row_stride);
- y++;
- } while(iter.PrevRow());
-// printf("Y=%d ",y);
- }
- delete[] row_pointers;
-
- /* read the rest of the file, getting any additional chunks
- in info_ptr */
- png_read_end(png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated */
- png_read_destroy(png_ptr, info_ptr, (png_info *)0);
-
- /* free the structures */
- delete(png_ptr);
- delete(info_ptr);
-
- /* close the file */
- fclose(fp);
-
- /* that's it */
- return TRUE;
+ int row_stride = info_ptr->width * ((pixel_depth+7)>>3);
+ // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride);
+// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth);
+
+ byte *row_pointers = new byte[row_stride];
+
+ /* turn on interlace handling */
+ if (info_ptr->interlace_type)
+ number_passes = png_set_interlace_handling(png_ptr);
+ else
+ number_passes = 1;
+// printf("NP = %d ", number_passes);
+
+ for (int pass=0; pass< number_passes; pass++) {
+ iter.upset();
+ int y=0;
+ do {
+// (unsigned char *)iter.GetRow();
+ if (info_ptr->interlace_type) {
+ if (pass>0)
+ iter.GetRow(row_pointers, row_stride);
+ png_read_row(png_ptr, row_pointers, NULL);
+ }
+ else
+ png_read_row(png_ptr, row_pointers, NULL);
+
+ iter.SetRow(row_pointers, row_stride);
+ y++;
+ } while(iter.PrevRow());
+// printf("Y=%d ",y);
+ }
+ delete[] row_pointers;
+
+ /* read the rest of the file, getting any additional chunks
+ in info_ptr */
+ png_read_end(png_ptr, info_ptr);
+
+ /* clean up after the read, and free any memory allocated */
+ png_read_destroy(png_ptr, info_ptr, (png_info *)0);
+
+ /* free the structures */
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* close the file */
+ fclose(fp);
+
+ /* that's it */
+ return TRUE;
- fp = fopen(filename, "wb");
- if (!fp)
- return FALSE;
-
- /* allocate the necessary structures */
- png_ptr = new (png_struct);
- if (!png_ptr)
- {
- fclose(fp);
- return FALSE;
- }
-
- info_ptr = new (png_info);
- if (!info_ptr)
- {
- fclose(fp);
- delete(png_ptr);
- return FALSE;
- }
-
- /* set error handling */
- if (setjmp(png_ptr->jmpbuf))
- {
- png_write_destroy(png_ptr);
- fclose(fp);
- delete(png_ptr);
- delete(info_ptr);
-
- /* If we get here, we had a problem reading the file */
- return FALSE;
- }
+ fp = fopen(wxConvFile.cWX2MB(filename), "wb");
+ if (!fp)
+ return FALSE;
+
+ /* allocate the necessary structures */
+ png_ptr = new (png_struct);
+ if (!png_ptr)
+ {
+ fclose(fp);
+ return FALSE;
+ }
+
+ info_ptr = new (png_info);
+ if (!info_ptr)
+ {
+ fclose(fp);
+ delete(png_ptr);
+ return FALSE;
+ }
+
+ /* set error handling */
+ if (setjmp(png_ptr->jmpbuf))
+ {
+ png_write_destroy(png_ptr);
+ fclose(fp);
+ delete(png_ptr);
+ delete(info_ptr);
+
+ /* If we get here, we had a problem reading the file */
+ return FALSE;
+ }
- /* set the file information here */
- info_ptr->width = GetWidth();
- info_ptr->height = GetHeight();
- info_ptr->pixel_depth = GetDepth();
- info_ptr->channels = (GetDepth()>8) ? 3: 1;
- info_ptr->bit_depth = GetDepth()/info_ptr->channels;
- info_ptr->color_type = GetColorType();
- info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
- info_ptr->valid = 0;
- info_ptr->rowbytes = row_stride;
+ /* set the file information here */
+ info_ptr->width = GetWidth();
+ info_ptr->height = GetHeight();
+ info_ptr->pixel_depth = GetDepth();
+ info_ptr->channels = (GetDepth()>8) ? 3: 1;
+ info_ptr->bit_depth = GetDepth()/info_ptr->channels;
+ info_ptr->color_type = GetColorType();
+ info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0;
+ info_ptr->valid = 0;
+ info_ptr->rowbytes = row_stride;
- /* set the palette if there is one */
- if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
- {
-// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
- info_ptr->valid |= PNG_INFO_PLTE;
- info_ptr->palette = new png_color[256];
- info_ptr->num_palette = 256;
- for (int i=0; i<256; i++)
- GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
- }
-// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+ /* set the palette if there is one */
+ if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette())
+ {
+// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
+ info_ptr->valid |= PNG_INFO_PLTE;
+ info_ptr->palette = new png_color[256];
+ info_ptr->num_palette = 256;
+ for (int i=0; i<256; i++)
+ GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue);
+ }
+// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette());
- byte *row_pointers = new byte[row_stride];
- iter.upset();
- do {
-// (unsigned char *)iter.GetRow();
- iter.GetRow(row_pointers, row_stride);
- png_write_row(png_ptr, row_pointers);
- } while(iter.PrevRow());
-
+ byte *row_pointers = new byte[row_stride];
+ iter.upset();
+ do {
+// (unsigned char *)iter.GetRow();
+ iter.GetRow(row_pointers, row_stride);
+ png_write_row(png_ptr, row_pointers);
+ } while(iter.PrevRow());
+